Hmbown/CodeWhale · error
Failed to validate runtime thread route
Error message
Failed to validate runtime thread route: {reason} What it means
When a turn start requires client preflight, the resolved route is validated with route.preflight(); any Err becomes 'Failed to validate runtime thread route: {reason}'. Preflight checks that the route's provider/model/sandbox configuration is actually usable from this client before the turn is admitted. This fails the turn start before any engine work happens.
Solutions
- Read the inner {reason} — preflight names the concrete validation failure
- Fix the provider credentials/endpoint in config so the route passes preflight
- Correct the route configuration (provider, model, sandbox mode) referenced by the thread
- If preflight should not be required for this turn, check why client_preflight_required was set rather than skipping it
Example fix
// before
let route = Route::from_config(cfg)?; // fails later at preflight
// after
let route = Route::from_config(cfg)?;
route.preflight().map_err(|e| anyhow!("route invalid: {e}"))?; // fail fast, same check Defensive patterns
Strategy: validation
Validate before calling
let route = build_route(&config)?;
route.preflight().map_err(|e| format!("route invalid: {e}"))?; // same check the runtime runs Try / catch
match start_turn(req).await {
Err(e) if e.to_string().contains("Failed to validate runtime thread route") => {
bail!("fix provider/model/credentials in config; preflight rejected the route: {e:#}");
}
other => other,
} Prevention
- Run route.preflight() in a startup config check
- Keep provider credentials and endpoints current in config
- Re-validate routes after upgrading providers or changing sandbox mode
When it happens
Trigger: Starting a turn where client_preflight_required is true and route.preflight() rejects the route — e.g. missing API key/credentials for the provider, unreachable provider endpoint configuration, or a route assembled from config that fails runtime validation.
Common situations: Missing or expired API key for the selected provider; a config route referencing a model the client cannot serve; proxy/endpoint misconfiguration caught at preflight time; provider removed or renamed in the config.
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
- account_agent_model_unconfigured
- agent profile provider cannot be empty
- agent profile provider must be a simple provider id
- api_key cannot be empty string
- approval_policy ' ' is not allowed by requirements ( )
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/a753891c80bca144.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/runtime_threads.rs:10047
route.identity.provider,
&route.candidate.endpoint().base_url,
&route.model,
)
.as_setting()
.to_string()
});
(
route,
reasoning_effort,
auto_controls_reasoning,
crate::cost_status::RuntimeUsageBatch::default(),
None,
)
};
let route = if client_preflight_required {
route
.preflight()
.map_err(|reason| anyhow!("Failed to validate runtime thread route: {reason}"))?
} else {
route
};
let configured_sandbox_mode = route.config.sandbox_mode.clone();
let provider = route.identity.provider;
let provider_identity = route.identity.clone();
let model = route.model.clone();
let route_limits = known_route_limits(route.candidate.limits());
let max_output_tokens = req.max_output_tokens.and_then(|requested| {
std::num::NonZeroU32::new(crate::route_budget::effective_max_output_tokens_for_turn(
provider, &model, route_limits, Some(requested),
))
});
let settings = crate::settings::Settings::load().unwrap_or_default();
let mut compaction = runtime_compaction_config(
&route.config,
provider,
&model,View on GitHub (pinned to 73e0f67d83)