fix(ai-connectors): preserve workspace fallback chain and node fallbackProviderKey when overrideProviderKey is set

Abierto
#52 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Start with dispatchWithFallback in packages/ai-connectors/src/gateway.ts and dispatchCompletion in apps/api/src/ai-connectors/ai-connectors.service.ts to trace how provider options reach the gateway and how candidates are ordered. Then read packages/ai-connectors/src/gateway.spec.ts and add coverage for fallback after an overridden provider fails. Done means the override is tried first, configured fallback providers are tried in order, and full-chain failure still triggers handoff.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

backend bug good first issue
Problem Description
  1. Node-level overrideProviderKey drops all configured backups:
    In packages/ai-connectors/src/gateway.ts (AiGatewayService.dispatchWithFallback, lines 50-98), when request.overrideProviderKey matches an active connector, candidates is populated with only that single provider. Because the remaining workspace connectors (fallbackTier 1, 2, 3) and optional systemFallbackKey are wrapped in if (candidates.length === 0) (lines 69 & 92), they are all skipped for that request.
    If the overridden provider returns 429 or times out, dispatchWithFallback immediately fails and triggers onFullChainFailure instead of falling back through the workspace's configured tiers.

  2. fallbackProviderKey and fallbackModelId are ignored:
    AiConnectorsService.dispatchCompletion (apps/api/src/ai-connectors/ai-connectors.service.ts, lines 475-494) accepts options.fallbackProviderKey and options.fallbackModelId (and AiCompletionRequest in packages/types/src/ai-connectors.ts lines 95-96 defines them), but mergedRequest never forwards them and gateway.ts never reads them.


Expected Behavior
  1. Setting overrideProviderKey should try that provider first — not discard the rest of the fallback chain.
  2. candidates should be built as an ordered, deduplicated list:
    1. overrideProviderKey / overrideModelId (if set and usable)
    2. fallbackProviderKey / fallbackModelId (if set and usable)
    3. Remaining active workspace connectors sorted by fallbackTier (Tier 1 -> Tier 2 -> Tier 3)
    4. Optional systemFallbackKey (only if configured)
  3. If every provider in the chain fails, onFullChainFailure (Human Handoff) still triggers as before.

Where to Look
  • packages/ai-connectors/src/gateway.ts (dispatchWithFallback, lines 40-102)
  • apps/api/src/ai-connectors/ai-connectors.service.ts (dispatchCompletion, lines 475-494)
  • packages/types/src/ai-connectors.ts (AiCompletionRequest, lines 88-99)
  • packages/ai-connectors/src/gateway.spec.ts

Solution / Implementation Guide
  1. Forward fallback options (ai-connectors.service.ts):
    • In dispatchCompletion (lines 490-494), include fallbackProviderKey and fallbackModelId in mergedRequest when provided in options.
  2. Build a deduplicated ordered candidates list (gateway.ts):
    • Remove the if (candidates.length === 0) guard around workspace connectors and systemFallbackKey.
    • Add a small helper addCandidate(...) keyed by ${providerKey}:${modelId} to append in order:
      1. request.overrideProviderKey / request.overrideModelId
      2. request.fallbackProviderKey / request.fallbackModelId
      3. Active connectors sorted by fallbackTier
      4. systemFallbackKey (when present)
  3. Add unit test (gateway.spec.ts):
    • Verify that when overrideProviderKey fails, dispatchWithFallback cascades to fallbackProviderKey / Tier 1 / Tier 2 connectors instead of failing immediately.
Lenguaje dominante
TypeScript
Estrellas
2
Forks
1
Merge medio
6 min
PR fusionados (30 d)
27

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sumamakhan761/tryinstance

Todos los issues de sumamakhan761/tryinstance

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.