Skip to content

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

fix: harden composer model routing

Steven Enamakeld00380dbf8bc
diff --git a/app/src/features/conversations/Conversations.processSourceCommand.test.tsx b/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
index cb198d690e..22e2ca8696 100644
--- a/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
+++ b/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
@@ -376,6 +376,8 @@ describe('composer model routing', () => {
afterEach(() => {
cleanup();
registry.reset();
+ vi.mocked(callCoreRpc).mockReset().mockResolvedValue({});
+ mockChatSend.mockReset().mockResolvedValue(undefined);
});
it('waits for a successful model clear before sending a normal default turn', async () => {
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index 9012d5442f..0bfc7c233c 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -1231,6 +1231,7 @@ const Conversations = ({
// this draft when the clear barrier prevents the send from starting.
preserveSendErrorForRestoredDraftRef.current = true;
setInputValue(normalized);
+ setAttachments(pendingAttachments);
throw error;
}
}
@@ -1396,6 +1397,7 @@ const Conversations = ({
// handles the transport error locally, so restore the rejected follow-up
// explicitly instead of letting the user's draft disappear.
setInputValue(normalized);
+ setAttachments(pendingAttachments);
}
};
diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rs
index 42a9442a90..2020057f32 100644
--- a/crates/openhuman-core/src/web_chat/session.rs
+++ b/crates/openhuman-core/src/web_chat/session.rs
@@ -116,6 +116,11 @@ fn effective_session_config(
// The factory matches configured slugs exactly; preserve its canonical slug
// while keeping the full selected model suffix, including extra colons.
effective.chat_provider = Some(format!("{}:{model_suffix}", entry.slug));
+ } else {
+ // Keep an unknown qualified selection on an invalid route so
+ // factory construction fails explicitly instead of silently
+ // using the previous chat provider.
+ effective.chat_provider = Some(model.to_string());
}
}
}
diff --git a/crates/openhuman-core/src/web_chat/session_routing_tests.rs b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
index 32db45471f..957bc21fba 100644
--- a/crates/openhuman-core/src/web_chat/session_routing_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
@@ -213,8 +213,8 @@ fn unknown_qualified_models_keep_the_existing_route() {
let effective = effective_session_config(&config, Some("unknown-provider:some-model"), None);
assert_eq!(
provider_for_role("chat", &effective),
- "openai:gpt-4o",
- "an unrecognized provider slug is not adopted as a picker route"
+ "unknown-provider:some-model",
+ "an unrecognized provider slug must remain invalid instead of falling back"
);
assert_eq!(
effective.default_model.as_deref(),
@@ -223,6 +223,21 @@ fn unknown_qualified_models_keep_the_existing_route() {
);
}
+#[test]
+fn selected_managed_route_constructs_with_the_picker_model() {
+ let config = Config::default();
+ let selection = "openrouter/author/picked-model:free";
+ let effective = effective_session_config(&config, Some(selection), None);
+ let (_, resolved_model) =
+ crate::inference::provider::factory::create_chat_model_with_model_id(
+ "chat",
+ &effective,
+ effective.default_temperature,
+ )
+ .expect("managed picker selection should construct without network access");
+ assert_eq!(resolved_model, selection);
+}
+
#[test]
fn selected_ollama_route_constructs_the_selected_model_without_network() {
let mut config = Config::default();
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index dc9d3d436e..d907e905c6 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -582,7 +582,7 @@ The thread JSONL store moved to `tinyagents_session::threads` (`vendor/tinyagent
| 13.3.8 | Managed default model (one OpenRouter model for every managed workload) | RU+RI | `crates/openhuman-core/src/inference/provider/factory_route_resolution_tests.rs` (`resolve_model_for_hint_maps_every_managed_hint_to_the_default_model`, `resolve_model_for_hint_uses_the_pinned_managed_default`, `resolve_model_for_hint_treats_retired_tier_slugs_as_role_aliases`), `crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs`, `crates/openhuman-core/src/agent/triage/routing_tests.rs`, `crates/openhuman-core/src/agent/cost_tests.rs`, `crates/openhuman-core/src/platform/cost/route_tests.rs`, `crates/openhuman-core/src/config/migrations/retire_managed_tier_slugs_tests.rs`, `crates/openhuman-core/src/config/migrations/mod_tests.rs` (`run_pending_v12_to_v13_*`), `tests/json_rpc_e2e.rs` (routing cases, flows arc) | ✅ | The `chat-v1`/`agentic-v1`/… tier endpoints are retired: every managed workload role resolves to `config.default_model` when it names a catalog model, else `openrouter/deepseek/deepseek-v4-flash`; `hint:*` and retired slugs stay role aliases; migration 12→13 rewrites persisted slugs; cost classification and the flash price row |
| 13.3.9 | Routing page: Default model row + per-workload tables always shown; providers header action | VU | `app/src/components/settings/panels/__tests__/AIPanel.test.tsx` (`shows the per-workload routing tables directly, with no mode selector`, `pins a managed default model from the routing page`), `app/src/services/api/__tests__/aiSettingsApi.test.ts` (`sends default_model only when the pinned default model changed`), `app/src/components/settings/panels/ai/ProviderModelPickerDialog.test.tsx` | ✅ | No Managed / Own / Advanced selector; the Default model row opens the managed catalog picker (list, alphabetical, search filters models) and persists `default_model`; "Add provider" lives in the page header |
-| 13.3.10 | Composer model pick is the global default | RU+RI+VU+PW | `app/test/playwright/specs/chat-model-managed-catalog.spec.ts` (`a composer pick is the global default and survives a fresh page`), `crates/openhuman-core/src/web_chat/session_routing_tests.rs`, `tests/json_rpc_e2e.rs`, `app/src/features/conversations/Conversations.processSourceCommand.test.tsx` | 🟡 | The managed catalog suite is active; its individual `a composer pick is the global default and survives a fresh page` case remains `test.skip` under #6395. Catalog display is exercised, while composer persistence across a fresh page remains unasserted by that skipped case. Partially backstopped meanwhile by 13.3.1’s new PW case, which pins the same `default_model` contract from the settings route rather than the composer pill. Backend provider/model routing is covered by `web_chat::session::session_routing_tests` (managed/local/BYOK, restored defaults, suffixes, sibling isolation, effective provider/model cache binding); Composer send defaults and explicit picker overrides are additionally covered for normal and queued follow-up sends by `Conversations.processSourceCommand.test.tsx` (`composer model routing`, including delayed and rejected clears). RI in `json_rpc_e2e.rs` extends the warm BYOK conversation through a managed picker override and two persisted managed defaults, asserting the outgoing path, model and credential; these checks do not replace the skipped persistence UI assertion. |
+| 13.3.10 | Composer model pick is the global default | RU+RI+VU+PW | `app/test/playwright/specs/chat-model-managed-catalog.spec.ts` (`Managed OpenRouter catalog in the model picker`), `crates/openhuman-core/src/web_chat/session_routing_tests.rs`, `tests/json_rpc_e2e.rs`, `app/src/features/conversations/Conversations.processSourceCommand.test.tsx` | 🟡 | The managed catalog suite is active and covers catalog display and selection. Its individual `a composer pick is the global default and survives a fresh page` case remains `test.skip` under #6395, so persistence across a fresh page is not asserted by Playwright. Backend provider/model routing is covered by `web_chat::session::session_routing_tests` and `tests/json_rpc_e2e.rs`; composer send defaults, picker overrides, delayed clears, rejected clears, and draft restoration are covered by `Conversations.processSourceCommand.test.tsx`. |
| 13.3.11 | Skills page (Installed → Registry) with run/edit/remove controls | VU | `app/src/components/skills/__tests__/SkillsExplorerTab.test.tsx` | ✅ | Page-owned header + tabs in the MCP page's shape: installed rows with Run / Edit / Remove icon controls, Install from URL and New skill; registry rows with search, source filter and Install |
### 13.4 Developer Options