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

Aperta
#52 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
2
Fork
1
Merge medio
6m
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sumamakhan761/tryinstance

Tutte le issue di sumamakhan761/tryinstance

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.