Hmbown/CodeWhale · error
Failed to resolve runtime thread route
Error message
Failed to resolve runtime thread route: {reason} What it means
resolve_runtime_thread_route wraps resolve_runtime_route and converts its failure into 'Failed to resolve runtime thread route: {reason}'. It is thrown when the configured provider/model combination cannot be resolved to a concrete route (provider identity, base URL, model) for a runtime thread. The inner reason carries the specifics.
Solutions
- Read the {reason} suffix — it names the unresolvable piece (provider, identity, or model selector).
- Check the Config's provider settings for the given ApiProvider: identity, base URL, and credentials are present.
- Verify the model_selector string matches a model registered for that provider exactly.
- If triggered after a config edit or upgrade, reconcile the config with the current provider registry and retry.
Example fix
// before: unknown selector
let route = resolve_runtime_thread_route(&cfg, ApiProvider::Anthropic, Some("claude-9-fake"))?;
// after: use a registered model
let route = resolve_runtime_thread_route(&cfg, ApiProvider::Anthropic, Some("claude-sonnet-4"))?; Defensive patterns
Strategy: validation
Validate before calling
// preflight the route before spawning the thread
let selector = Some("claude-sonnet-4");
let known = cfg.models_for(cfg.api_provider()).iter().any(|m| Some(&m.name) == selector);
anyhow::ensure!(known || selector.is_none(), "unknown model selector");
Try / catch
let route = match resolve_runtime_thread_route(&cfg, provider, selector) {
Ok(r) => r,
Err(e) => { log::error!("route resolution failed: {e:#}"); return Err(e); }
};
Prevention
- Validate model selector strings against the registry at config load time.
- Keep provider identity/base-url/credentials complete for every ApiProvider in use.
- Re-run route preflight after any config edit or upgrade.
- Avoid free-text model names; use constants from the model registry.
When it happens
Trigger: Starting or preflighting a runtime thread when config's provider/model settings cannot be resolved: unknown provider enum value, missing provider identity, unresolvable model_selector string, or missing route configuration for the given ApiProvider.
Common situations: Typo'd model selector string passed to thread creation; config referencing a provider removed or renamed in this version; missing base-url/api-key config for a custom provider; config reload left stale provider settings.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Choose both a provider and a model.
- Fleet task ` ` has no provider authority for model ` `…
- Fleet task ` ` names custom provider=` `, but a provider…
- maxOutputTokens requires an exact model
- .model_context_windows. must be greater than 0
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/56b4c53848927880.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:4314
bucket
.unpriced_reasons
.insert("provider_success_missing_usage".to_string());
bucket
.cny_unpriced_reasons
.insert("provider_success_missing_usage".to_string());
}
bucket
.route_receipts
.insert(format!("{} usage=missing", route.receipt(&audit)));
}
fn resolve_runtime_thread_route(
config: &Config,
provider: ApiProvider,
model_selector: Option<&str>,
) -> Result<ResolvedRuntimeRoute> {
resolve_runtime_route(config, provider, model_selector)
.map_err(|reason| anyhow!("Failed to resolve runtime thread route: {reason}"))
}
fn resolve_runtime_thread_route_for_identity(
config: &Config,
identity: &ProviderIdentity,
model_selector: Option<&str>,
) -> Result<ResolvedRuntimeRoute> {
resolve_runtime_route_for_identity(config, identity, model_selector)
.map_err(|reason| anyhow!("Failed to resolve runtime thread route: {reason}"))
}
fn runtime_compaction_config(
config: &Config,
provider: ApiProvider,
model: &str,
route_limits: Option<codewhale_config::route::RouteLimits>,
auto_compact: bool,
auto_compact_explicit: bool,View on GitHub (pinned to 73e0f67d83)