fix(kernel): resolve "default" provider in fallback_models before driver init#710
fix(kernel): resolve "default" provider in fallback_models before driver init#710Reaster0 wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
…ver init
The fallback model loop passed `provider = "default"` verbatim to
`create_driver()`, which only recognises real provider names (ollama,
openai, anthropic, …). The primary model overlay at spawn_agent()
already resolves "default" → kernel config, but fallback_models was
skipped, causing every bundled agent with a "default" fallback to log:
Fallback driver 'default' failed to init: Unknown provider 'default'
This meant agents had zero fallback drivers, silently degrading
resilience for anyone whose config.toml sets a non-standard default
provider (e.g. ollama pointing at a local proxy).
Changes:
- Mirror the primary-model overlay logic for fallback entries:
resolve provider, model, api_key_env, and base_url from
`config.default_model` when the fallback specifies "default" or empty.
- Inherit `base_url` from default_model before falling back to
`lookup_provider_url()`, so custom endpoints propagate correctly.
- Use resolved values in `strip_provider_prefix()` and warn messages.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jaberjaber23
left a comment
There was a problem hiding this comment.
Two bugs in the implementation:
-
base_url leaks across providers. The PR unconditionally inherits
dm.base_urlfor all fallback providers via.or_else(|| dm.base_url.clone()). But the primary model logic explicitly guards this withif agent_provider == default_provider(with comment "Don't inherit default provider's base_url when switching providers"). If default is ollama withbase_url = "http://localhost:11434", an openai fallback would incorrectly get ollama's URL. Must guard withfb_provider == dm.provider. -
Ignores hot-reload. The PR uses
&self.config.default_modeldirectly, but primary resolution readsself.default_model_overridefirst (the hot-reload mechanism for dashboard model changes). Should useeffective_defaultalready computed at line 4614. -
Dead
let _ = &fb_model_name;line — does nothing, fb_model_name is already used on the next line. -
Zero tests added for a kernel-level driver init change. Need at minimum: "default" provider resolves correctly, cross-provider base_url doesn't leak, empty strings resolve to default.
The fix direction is correct but needs these issues addressed.
Summary
provider = "default"were passed verbatim tocreate_driver(), which only recognises real provider names (ollama,openai,anthropic, …)"default"→ kernel config atspawn_agent(), but the fallback loop was missing the same resolution — causing every bundled agent with a"default"fallback to silently lose all fallback drivers:config.tomlsets a non-standard default provider (e.g.ollamapointing at a local proxy), where the fallback is the only recovery pathChanges
provider,model,api_key_env, andbase_urlfromconfig.default_modelwhen the fallback specifies"default"or empty stringbase_urlfromdefault_modelbefore falling back tolookup_provider_url(), so custom endpoints propagate correctlystrip_provider_prefix()and warn messagesTest plan
cargo build --workspace --libcompilescargo test --workspace— existing tests pass (no signature changes to public API)[default_model] provider = "ollama"and an agent with[[fallback_models]] provider = "default"— verify theUnknown provider 'default'warning is gone🤖 Generated with Claude Code