Skip to content

Providers & Routing ​

Model calls are never hard-coded into agents: each request resolves tier → route → provider adapter, with the capability_routes table as the single source of truth. Swapping models, rotating keys or degrading offline only changes routes, never code.

Route resolution ​

Route keys: chat.cheap / chat.fast / chat.strong / embedding / asr / search. Each route records provider / engine / model / locality (local | cloud) — whether a call egresses is visible at the routing layer.

Seed providers and default routes ​

ProviderScopeProtocolDefault modelInitial state
mocklocalmock—enabled, undeletable
deepseeksharedopenaideepseek-chatenabled
anthropicprivateanthropicclaude-sonnet-4-5enabled
ollamalocalopenai (127.0.0.1:11434)qwen2.5:7bdisabled

Default routes: chat.cheap → mock; chat.fast → deepseek (engine deepseek-flash, model default deepseek-chat, overridable via IFG_DEEPSEEK_FAST); chat.strong → deepseek (engine deepseek-v4-pro, model default deepseek-reasoner, overridable via IFG_DEEPSEEK_STRONG); embedding → local hashed-256 fallback; asr / search → mock. Without cloud keys, fast/strong fall to mock and the product still runs end to end.

Keys: encrypted at rest, never echoed ​

  • SecretStore: AES-256-GCM; master key at dataDir/keys/master.key (randomBytes(32), mode 0600), the local fallback for the macOS Keychain.
  • Ciphertext format v1.<iv>.<tag>.<cipher> (three base64url segments); decryption verifies the auth tag, and corrupt ciphertext returns undefined instead of throwing.
  • Rotation leaves a trail: the old key's masked reference goes into provider_key_history (actor + timestamp, query cap 50).
  • APIs return only hasKey / available booleans — no endpoint ever echoes key plaintext or ciphertext.

Permission boundaries ​

  • A member may rotate keys of private providers only; shared providers, route edits, probes and deletes are admin-only — otherwise a member could point the admin's key at their own server.
  • Profile identity binds to the verified token (profileOf), never the client-controlled x-ifg-profile header.
  • A probe sends the stored key to the configured base URL, so only admins may trigger it: one ping, maxTokens: 8, 8 s timeout, returning latencyMs and a ≤40-char sample; the mock protocol returns ok directly.
  • Deleting a provider resets every route pointing at it to mock / local — no dangling routes; mock itself cannot be deleted.

Failure and degradation: three cases, three treatments ​

CaseTreatment
request aborted / timed outthrow directly, no mock retry — retrying would hide the abort and burn a step
failure after partial text emittedprovider_midstream, retryable: false + partialChars; replay would duplicate text, so retry is explicit and user-initiated
failure before any textmock completes the step, carrying a fallback reason (≤300 chars)

Each fallback writes a provider.fallback event; report assembly counts them and marks the report degraded when >0 — scores produced by local rules never impersonate model scores. Session-level idempotency and stream-break handling are in Agent Kernel & Sessions.

Local-first · inference egresses on demand · fully traceable