Skip to content

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

fix(routing): honour bare provider names in default_model route

Saim Shafique30f08cb4f3a9
diff --git a/crates/openhuman-core/src/inference/provider/factory/routing.rs b/crates/openhuman-core/src/inference/provider/factory/routing.rs
index 3f4ce5c19d..1f220a8814 100644
--- a/crates/openhuman-core/src/inference/provider/factory/routing.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/routing.rs
@@ -145,7 +145,9 @@ 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.
+/// 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.
fn default_model_route_for_role(role: &str, config: &Config) -> Option<String> {
match role {
"chat" | "reasoning" | "agentic" | "coding" | "burst" => {}
@@ -155,6 +157,19 @@ 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).
+ 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());
+ }
let (slug, rest) = dm.split_once(':')?;
let slug = slug.trim();
if slug.is_empty() || slug == PROVIDER_OPENHUMAN || rest.trim().is_empty() {
@@ -163,7 +178,6 @@ fn default_model_route_for_role(role: &str, config: &Config) -> Option<String> {
let known = config.cloud_providers.iter().any(|e| e.slug == slug)
|| tinyinference_local::profile::is_local_provider_string(dm)
|| dm.starts_with(tinyagents_harness::providers::claude_code::PROVIDER_PREFIX)
- || dm == CLAUDE_AGENT_SDK_PROVIDER
|| dm.starts_with(CLAUDE_AGENT_SDK_PREFIX);
known.then(|| dm.to_string())
}
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 0527bda115..fc5f0bac5a 100644
--- a/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/routing_tests.rs
@@ -169,3 +169,78 @@ fn default_model_does_not_disturb_configured_sibling_routes() {
"the unset reasoning route falls back to the default_model pick, not the sibling's route"
);
}
+
+/// tinysweeper review on #6996: a bare `claude_agent_sdk` default names the
+/// provider with no `:model` part. The old `split_once(':')?` rejected it
+/// before the explicit `CLAUDE_AGENT_SDK_PROVIDER` check could run, silently
+/// falling back to the managed backend.
+#[test]
+fn default_model_with_bare_claude_agent_sdk_routes_chat() {
+ let mut config = Config::default();
+ config.default_model = Some("claude_agent_sdk".to_string());
+
+ assert_eq!(
+ provider_for_role("chat", &config),
+ "claude_agent_sdk",
+ "a bare claude_agent_sdk pick must route the chat turn"
+ );
+ assert!(
+ !resolves_to_managed_backend("chat", &config),
+ "a bare claude_agent_sdk pick must not resolve to the managed backend"
+ );
+}
+
+/// 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.
+#[test]
+fn default_model_with_bare_local_provider_routes_chat_locally() {
+ 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"
+ );
+ assert!(
+ !resolves_to_managed_backend("chat", &config),
+ "a bare ollama pick must not resolve to the managed backend"
+ );
+}
+
+/// A bare configured cloud slug is an explicit route as well.
+#[test]
+fn default_model_with_bare_cloud_slug_routes_chat() {
+ 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"
+ );
+ assert!(
+ !resolves_to_managed_backend("chat", &config),
+ "a bare configured cloud slug must not resolve to the managed backend"
+ );
+}
+
+/// Bare `openai` is deliberately NOT rerouted: the `openai` slug names the
+/// cloud provider elsewhere in the factory, so it keeps the managed fallback
+/// rather than being misread as a local runtime.
+#[test]
+fn default_model_with_bare_openai_keeps_managed_fallback() {
+ let mut config = Config::default();
+ config.default_model = Some("openai".to_string());
+
+ assert_eq!(
+ provider_for_role("chat", &config),
+ "openhuman",
+ "bare openai must keep the managed fallback"
+ );
+ assert!(
+ resolves_to_managed_backend("chat", &config),
+ "bare openai must resolve to the managed backend"
+ );
+}