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
| Provider | Scope | Protocol | Default model | Initial state |
|---|---|---|---|---|
mock | local | mock | — | enabled, undeletable |
deepseek | shared | openai | deepseek-chat | enabled |
anthropic | private | anthropic | claude-sonnet-4-5 | enabled |
ollama | local | openai (127.0.0.1:11434) | qwen2.5:7b | disabled |
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 atdataDir/keys/master.key(randomBytes(32), mode0600), 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/availablebooleans — 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-controlledx-ifg-profileheader. - A probe sends the stored key to the configured base URL, so only admins may trigger it: one
ping,maxTokens: 8, 8 s timeout, returninglatencyMsand 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
| Case | Treatment |
|---|---|
| request aborted / timed out | throw directly, no mock retry — retrying would hide the abort and burn a step |
| failure after partial text emitted | provider_midstream, retryable: false + partialChars; replay would duplicate text, so retry is explicit and user-initiated |
| failure before any text | mock 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.