Skip to content

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

fix(inference): a chat-tier route no longer inherits a sibling's BYOK provider\n\n`provider_for_role` let `chat`, `reasoning` and `coding` fall back to any\nconfigured BYOK route found on a sibling. A user who set only\n\n coding_provider = "openrouter:zai/glm-4.7"\n\nfound that `chat` and `reasoning` resolved there too — ordinary\nconversations and reasoning turns moved onto their own key and off the\nmanaged backend, billed to them, with no settings field saying so. The\nrelation was not even symmetric: `agentic_provider` was read as a donor\nbut never received a route.\n\nPer the decision on #6109 each chat-tier route now stands alone. An\nunset route falls through to `primary_cloud`, the same as every other\nworkload.\n\n`resolve_byok_fallback_provider_string` existed only to feed that\nfallback and has no other caller, so it goes with it — left in place it\nwould be a `pub(crate)` fn reachable only from `#[cfg(test)]`, which\ntrips `dead_code`. Its two unit tests asserted that *local* providers\nwere ineligible for inheritance; since inheritance is gone they now\nassert the stronger property through the public seam — an unset route\ninherits nothing at all.\n\nThe doc comment on `provider_for_role` and the `vision` note in\n`configured_route_for_role` both described the inheritance and are\nupdated.\n\nCloses #6109\n

M3gA-Mind953cb7fdd2d7
diff --git a/src/openhuman/inference/provider/factory_part_01.rs b/src/openhuman/inference/provider/factory_part_01.rs
index aecd724173..5b5b831fcb 100644
--- a/src/openhuman/inference/provider/factory_part_01.rs
+++ b/src/openhuman/inference/provider/factory_part_01.rs
@@ -292,9 +292,8 @@ fn configured_route_for_role<'a>(role: &str, config: &'a Config) -> Option<&'a s
// If unset, it falls through to the managed backend and is pinned to
// `burst-v1` by `managed_tier_for_role`.
"burst" => config.agentic_provider.as_deref(),
- // Tier-specific multimodal model; like `agentic` it is NOT part of the
- // chat-tier BYOK inheritance below — when unset it falls through to
- // `primary_cloud` (→ managed `vision-v1`).
+ // Tier-specific multimodal model; when unset it falls through to
+ // `primary_cloud` (→ managed `vision-v1`), as every unset route now does.
"vision" => config.vision_provider.as_deref(),
// `memory_provider` covers both the memory-tree extract path and
// the summarizer sub-agent (whose definition declares
@@ -328,17 +327,15 @@ pub(crate) fn role_uses_implicit_cloud_fallback(role: &str, config: &Config) ->
/// Return the configured provider string for a named workload role.
///
-/// Empty / `"cloud"` resolves through BYOK fallback first for the three
-/// chat-tier roles (`chat`, `reasoning`, `coding`), then `primary_cloud`.
-/// When a BYOK cloud provider is detected on any workload, unset chat-tier
-/// routes inherit it rather than silently falling back to the managed backend.
+/// Empty / `"cloud"` resolves to `primary_cloud`. **Every** role behaves this
+/// way: a route that is not set falls through to the managed backend, and no
+/// role inherits another role's provider.
///
-/// Only `chat`, `reasoning`, and `coding` participate in BYOK inheritance.
-/// Background workloads (`memory`, `embeddings`, `heartbeat`, `learning`,
-/// `subconscious`) and the `agentic`/`burst` workloads always fall through to
-/// `primary_cloud` when their explicit provider route is unset — they use
-/// tier-specific models that BYOK providers don't understand, and their
-/// providers are configured independently.
+/// Until #6109 the three chat-tier roles (`chat`, `reasoning`, `coding`) took a
+/// configured BYOK provider from *any* sibling first, so setting one route moved
+/// the other two onto that key — a user who pointed only `coding_provider` at
+/// their own OpenRouter account found ordinary chat billed there too, with no
+/// setting saying so. Each route now stands alone.
///
/// For backwards compatibility, a legacy external `inference_url` takes
/// precedence when `primary_cloud` still points at OpenHuman because
@@ -348,21 +345,12 @@ pub fn provider_for_role(role: &str, config: &Config) -> String {
let opt = configured_route_for_role(role, config);
let s = opt.unwrap_or("").trim();
if s.is_empty() || s == "cloud" {
- // BYOK inheritance is scoped to the three chat-tier roles only.
- // Background workloads (memory, embeddings, heartbeat, learning,
- // subconscious) and the agentic/burst workloads must stay on the managed
- // backend when unset — they use tier-specific models that BYOK providers
- // don't understand, and their providers are configured separately.
- if matches!(role, "chat" | "reasoning" | "coding") {
- if let Some(byok) = resolve_byok_fallback_provider_string(config) {
- log::debug!(
- "[providers][byok-fallback] role={} inheriting BYOK provider string={}",
- role,
- byok
- );
- return byok;
- }
- }
+ // #6109: an unset chat-tier route no longer inherits a sibling's BYOK
+ // provider. Setting only `coding_provider` used to move `chat` and
+ // `reasoning` onto that key too — ordinary conversations silently billed
+ // to the user's own account, with no settings field saying so. Each
+ // route now stands alone and an unset one falls through to the managed
+ // backend, the same as every other workload.
let resolved = resolve_primary_cloud_provider_string(config);
@@ -463,48 +451,6 @@ fn route_has_usable_credentials(resolved: &str, config: &Config) -> bool {
false
}
-/// Find the first BYOK cloud provider string configured across all workload
-/// routes, skipping local providers and managed-backend sentinels
-/// ("openhuman", "cloud", empty).
-///
-/// Returns `None` when no BYOK cloud provider is configured, in which case
-/// the caller should fall through to `resolve_primary_cloud_provider_string`.
-///
-/// Priority order: chat → reasoning → agentic → coding (user-facing workloads
-/// first so the most prominent setting wins for unset background workloads).
-pub(crate) fn resolve_byok_fallback_provider_string(config: &Config) -> Option<String> {
- let candidates = [
- config.chat_provider.as_deref(),
- config.reasoning_provider.as_deref(),
- config.agentic_provider.as_deref(),
- config.coding_provider.as_deref(),
- ];
- for candidate in candidates.iter().flatten() {
- let s = candidate.trim();
- if s.is_empty() || s == "cloud" || s == PROVIDER_OPENHUMAN {
- continue;
- }
- // Skip local providers — they are not suitable fallbacks for agentic
- // or background workloads that run on the managed backend.
- if s.starts_with(OLLAMA_PROVIDER_PREFIX)
- || s.starts_with(LM_STUDIO_PROVIDER_PREFIX)
- || s.starts_with(MLX_PROVIDER_PREFIX)
- || s.starts_with(OMLX_PROVIDER_PREFIX)
- || s.starts_with(LOCAL_OPENAI_PROVIDER_PREFIX)
- {
- continue;
- }
- // Any remaining non-empty string with a colon is a BYOK cloud slug.
- if s.contains(':') {
- log::debug!(
- "[providers][byok-fallback] resolve_byok_fallback found candidate={}",
- s
- );
- return Some(s.to_string());
- }
- }
- None
-}
/// Human-readable label for an *external* provider string, used in the
/// LocalOnly privacy-mode block message so the user knows what was refused.
diff --git a/src/openhuman/inference/provider/factory_tests_part_01_tests.rs b/src/openhuman/inference/provider/factory_tests_part_01_tests.rs
index c1b14978c7..b8e179585c 100644
--- a/src/openhuman/inference/provider/factory_tests_part_01_tests.rs
+++ b/src/openhuman/inference/provider/factory_tests_part_01_tests.rs
@@ -156,32 +156,77 @@ fn ollama_provider_passes_num_ctx() {
// E2E suite; here we just confirm the factory doesn't reject it.
}
+// #6109 removed `resolve_byok_fallback_provider_string` along with the chat-tier
+// inheritance it fed. These two cases previously asserted that *local* providers
+// were not eligible to be inherited; they now assert the stronger property that
+// replaced it — an unset route inherits nothing at all — through the public seam.
+
#[test]
-fn byok_fallback_skips_mlx_and_local_openai() {
+fn unset_route_does_not_inherit_a_local_sibling() {
let mut config = Config::default();
config.chat_provider = Some("mlx:llama3".to_string());
config.reasoning_provider = Some("local-openai:phi3".to_string());
- // Neither should be picked up as a BYOK fallback
- let result = resolve_byok_fallback_provider_string(&config);
- assert!(
- result.is_none(),
- "local providers must not be BYOK fallbacks"
+ assert_eq!(
+ provider_for_role("coding", &config),
+ "openhuman",
+ "an unset coding route must fall through to the managed backend"
);
}
#[test]
-fn byok_fallback_skips_omlx() {
+fn unset_route_does_not_inherit_omlx() {
let mut config = Config::default();
config.chat_provider = Some("omlx:llama3".to_string());
-
- assert!(
- resolve_byok_fallback_provider_string(&config).is_none(),
- "OMLX is a local provider and must not be treated as a BYOK cloud fallback"
+ assert_eq!(
+ provider_for_role("coding", &config),
+ "openhuman",
+ "unset coding must not pick up chat's OMLX route"
);
+}
+
+/// The #6109 regression itself: a user who configures exactly one chat-tier
+/// route must not find the other two moved onto it. Before the fix,
+/// `coding_provider` alone re-routed both `chat` and `reasoning` to
+/// `openrouter:zai/glm-4.7` — their ordinary conversations billed to their own
+/// key, with no settings field saying so.
+#[test]
+fn setting_one_chat_tier_route_leaves_its_siblings_on_the_managed_backend() {
+ let mut config = Config::default();
+ config.coding_provider = Some("openrouter:zai/glm-4.7".to_string());
+
assert_eq!(
provider_for_role("coding", &config),
+ "openrouter:zai/glm-4.7",
+ "the route the user actually set must be honoured"
+ );
+ for sibling in ["chat", "reasoning"] {
+ assert_eq!(
+ provider_for_role(sibling, &config),
+ "openhuman",
+ "`{sibling}` was never configured and must stay on the managed backend, \
+ not inherit the coding route"
+ );
+ }
+}
+
+/// The relation was not even symmetric before the fix: `agentic_provider` was
+/// read as a donor but never received a route. Both directions are now inert.
+#[test]
+fn agentic_route_is_neither_donor_nor_beneficiary() {
+ let mut config = Config::default();
+ config.agentic_provider = Some("openrouter:some/model".to_string());
+ assert_eq!(
+ provider_for_role("chat", &config),
+ "openhuman",
+ "chat must not inherit the agentic route"
+ );
+
+ let mut config = Config::default();
+ config.chat_provider = Some("openrouter:some/model".to_string());
+ assert_eq!(
+ provider_for_role("agentic", &config),
"openhuman",
- "unset coding must not inherit chat OMLX as a BYOK fallback"
+ "agentic must not inherit the chat route"
);
}