Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(routing): only bare claude_agent_sdk is a routable bare provider

Saim Shafiquee433349b2775
diff --git a/crates/openhuman-core/src/inference/provider/factory/routing.rs b/crates/openhuman-core/src/inference/provider/factory/routing.rs
index 1f220a8814..d8034b69e9 100644
--- a/crates/openhuman-core/src/inference/provider/factory/routing.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/routing.rs
@@ -145,9 +145,11 @@ pub fn provider_for_role(role: &str, config: &Config) -> String {
/// explicit route: tier hints (`hint:chat`), the AI settings row's managed
/// catalog pin (`openrouter/<author>/<slug>[:tag]` — a model name for the
/// managed backend, see `DefaultModelRow.tsx`), bare model ids, and slugs
-/// that name no configured provider. Bare provider names (`claude_agent_sdk`,
-/// `ollama`, a configured cloud slug) carry no `:model` part but are explicit
-/// routes, so they are honoured.
+/// that name no configured provider. The one bare provider name that is
+/// honoured is `claude_agent_sdk`: unlike local runtimes and cloud slugs,
+/// which need a `:model` part to construct, the SDK falls back to
+/// `config.claude_agent_sdk.default_model` (see
+/// `claude_agent_sdk_model_from_string`).
fn default_model_route_for_role(role: &str, config: &Config) -> Option<String> {
match role {
"chat" | "reasoning" | "agentic" | "coding" | "burst" => {}
@@ -157,18 +159,14 @@ fn default_model_route_for_role(role: &str, config: &Config) -> Option<String> {
if dm.is_empty() || dm.starts_with("hint:") || dm.starts_with("openrouter/") {
return None;
}
- // Bare provider names carry no `:model` part — the Chat UI picker records
- // provider-level picks like `claude_agent_sdk` or `ollama` verbatim.
- // Check them before the slug:model split below, which would otherwise
- // reject them outright (tinysweeper review on #6996).
+ // Bare `claude_agent_sdk` is the only bare provider name honoured here:
+ // the SDK resolves its model from `config.claude_agent_sdk.default_model`
+ // (see `claude_agent_sdk_model_from_string`), while bare local runtimes
+ // (`ollama`, ...) and bare cloud slugs carry no `:model` part and fail
+ // at construction — they keep the managed fallback rather than erroring
+ // (tinysweeper review on #6996; CodeRabbit review on #6996).
if !dm.contains(':') {
- // Bare `openai` keeps the managed fallback: the `openai` slug names
- // the cloud provider elsewhere in the factory (see `cloud_slug.rs`),
- // so it is not read as a local runtime despite `from_str_loose`.
- let bare_known = dm == CLAUDE_AGENT_SDK_PROVIDER
- || config.cloud_providers.iter().any(|e| e.slug == dm)
- || (dm != "openai" && tinyinference_local::profile::is_local_provider_string(dm));
- return bare_known.then(|| dm.to_string());
+ return (dm == CLAUDE_AGENT_SDK_PROVIDER).then(|| dm.to_string());
}
let (slug, rest) = dm.split_once(':')?;
let slug = slug.trim();
diff --git a/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs b/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
index fc5f0bac5a..109b68a11d 100644
--- a/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
@@ -190,39 +190,43 @@ fn default_model_with_bare_claude_agent_sdk_routes_chat() {
);
}
-/// Bare local provider names (`ollama` with no `:model` part) are explicit
-/// routes too — the egress gate treats a bare `ollama` slug as a provider
-/// string, so routing must agree.
+/// Bare local provider names (`ollama` with no `:model` part) keep the managed
+/// fallback: the local runtime constructor rejects an empty model
+/// (`empty_model_err` in `local_runtime.rs`), so routing there would only
+/// trade the managed backend for a build-time error (CodeRabbit review on
+/// #6996).
#[test]
-fn default_model_with_bare_local_provider_routes_chat_locally() {
+fn default_model_with_bare_local_provider_keeps_managed_fallback() {
let mut config = Config::default();
config.default_model = Some("ollama".to_string());
assert_eq!(
provider_for_role("chat", &config),
- "ollama",
- "a bare ollama pick must route the chat turn locally"
+ "openhuman",
+ "a bare ollama pick has no model id and must keep the managed fallback"
);
assert!(
- !resolves_to_managed_backend("chat", &config),
- "a bare ollama pick must not resolve to the managed backend"
+ resolves_to_managed_backend("chat", &config),
+ "a bare ollama pick must resolve to the managed backend"
);
}
-/// A bare configured cloud slug is an explicit route as well.
+/// A bare cloud slug (`my-openai` with no `:model` part) is not constructible
+/// either — the cloud-slug path requires the `<slug>:<model>` form — so it
+/// keeps the managed fallback as well.
#[test]
-fn default_model_with_bare_cloud_slug_routes_chat() {
+fn default_model_with_bare_cloud_slug_keeps_managed_fallback() {
let mut config = config_with_byok_provider();
config.default_model = Some("my-openai".to_string());
assert_eq!(
provider_for_role("chat", &config),
- "my-openai",
- "a bare configured cloud slug must route the chat turn"
+ "openhuman",
+ "a bare cloud slug has no model id and must keep the managed fallback"
);
assert!(
- !resolves_to_managed_backend("chat", &config),
- "a bare configured cloud slug must not resolve to the managed backend"
+ resolves_to_managed_backend("chat", &config),
+ "a bare cloud slug must resolve to the managed backend"
);
}