Skip to content

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

fix(chat): honor selected and persisted provider routes

Sayr Wolfridgeddaaf20c92cf
diff --git a/app/src/features/conversations/Conversations.processSourceCommand.test.tsx b/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
index 5a9d6f0996..03ad0354d8 100644
--- a/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
+++ b/app/src/features/conversations/Conversations.processSourceCommand.test.tsx
@@ -9,7 +9,7 @@
* swapped, so the overlays (and the command) are live in both modes.
*/
import { combineReducers, configureStore } from '@reduxjs/toolkit';
-import { act, cleanup, render } from '@testing-library/react';
+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -27,32 +27,61 @@ import threadTodosReducer from '../../store/threadTodosSlice';
import type { Thread } from '../../types/thread';
import Conversations from './Conversations';
-const { mockGetThreads, mockGetThreadMessages, mockUseUsageState } = vi.hoisted(() => ({
- mockGetThreads: vi.fn().mockResolvedValue({ threads: [], count: 0 }),
- mockGetThreadMessages: vi.fn().mockResolvedValue({ messages: [], count: 0 }),
- mockUseUsageState: vi.fn(() => ({
- teamUsage: null,
- currentPlan: null,
- currentTier: 'FREE' as const,
- isFreeTier: true,
- usagePct: 0,
- isNearLimit: false,
- isAtLimit: false,
- isBudgetExhausted: false,
- shouldShowBudgetCompletedMessage: false,
- isLoading: false,
- refresh: vi.fn(),
- })),
-}));
+const { mockGetThreads, mockGetThreadMessages, mockUseUsageState, mockChatSend } = vi.hoisted(
+ () => ({
+ mockGetThreads: vi.fn().mockResolvedValue({ threads: [], count: 0 }),
+ mockGetThreadMessages: vi.fn().mockResolvedValue({ messages: [], count: 0 }),
+ mockChatSend: vi.fn().mockResolvedValue(undefined),
+ mockUseUsageState: vi.fn(() => ({
+ teamUsage: null,
+ currentPlan: null,
+ currentTier: 'FREE' as const,
+ isFreeTier: true,
+ usagePct: 0,
+ isNearLimit: false,
+ isAtLimit: false,
+ isBudgetExhausted: false,
+ shouldShowBudgetCompletedMessage: false,
+ isLoading: false,
+ refresh: vi.fn(),
+ })),
+ })
+);
vi.mock('../../services/chatService', () => ({
chatCancel: vi.fn().mockResolvedValue({ accepted: true, turnCancelled: true }),
chatClearQueue: vi.fn().mockResolvedValue(0),
- chatSend: vi.fn().mockResolvedValue(undefined),
+ chatSend: mockChatSend,
subscribeChatEvents: vi.fn(() => () => {}),
useRustChat: vi.fn(() => true),
}));
+vi.mock('../../components/chat/ModelQualityPill', async importOriginal => {
+ const actual = await importOriginal<typeof import('../../components/chat/ModelQualityPill')>();
+ return { ...actual, useModelPickerProviders: () => ({ providers: [], loading: false }) };
+});
+
+vi.mock('../../components/settings/panels/ai/ProviderModelPickerDialog', () => ({
+ ProviderModelPickerDialog: ({
+ onSelect,
+ }: {
+ onSelect: (selection: {
+ source: { kind: 'cloud'; providerSlug: string };
+ model: string;
+ }) => void;
+ }) => (
+ <div data-testid="provider-model-picker-dialog">
+ <button
+ type="button"
+ onClick={() =>
+ onSelect({ source: { kind: 'cloud', providerSlug: 'huggingface' }, model: 'org/model' })
+ }>
+ Pick Hugging Face model
+ </button>
+ </div>
+ ),
+}));
+
vi.mock('../../services/api/threadApi', () => ({
threadApi: {
createNewThread: vi.fn().mockResolvedValue({ id: 'new-thread', labels: [] }),
@@ -134,13 +163,17 @@ function buildStore(preload: Record<string, unknown>) {
});
}
-async function renderChat(composer?: 'text' | 'mic-cloud', withProcessData = false) {
+async function renderChat(
+ composer?: 'text' | 'mic-cloud',
+ withProcessData = false,
+ active = false
+) {
mockGetThreads.mockResolvedValue({ threads: [thread], count: 1 });
const store = buildStore({
thread: {
threads: [thread],
selectedThreadId: THREAD_ID,
- activeThreadIds: {},
+ activeThreadIds: active ? { [THREAD_ID]: true } : {},
welcomeThreadId: null,
messagesByThreadId: { [THREAD_ID]: [] },
messages: [],
@@ -174,6 +207,25 @@ async function renderChat(composer?: 'text' | 'mic-cloud', withProcessData = fal
});
}
+async function submitComposerText(text: string) {
+ const input = screen.getByRole('textbox');
+ await act(async () => {
+ input.textContent = text;
+ fireEvent.input(input, { data: text, inputType: 'insertText' });
+ });
+ const sendButton = screen.getByTestId('send-message-button');
+ await waitFor(() => expect(sendButton).not.toBeDisabled());
+ await act(async () => {
+ fireEvent.click(sendButton);
+ });
+ await waitFor(() => expect(mockChatSend).toHaveBeenCalledTimes(1));
+}
+
+async function selectPickerModel() {
+ fireEvent.click(screen.getByTestId('composer-chat-settings'));
+ fireEvent.click(await screen.findByRole('button', { name: 'Pick Hugging Face model' }));
+}
+
// The predicate's other half (`selectedThreadId !== null`) is deliberately not
// asserted here: on `/chat` it is unreachable as a steady state. The boot effect
// reuses an empty thread or calls `handleCreateNewThread`, so the page always
@@ -211,3 +263,50 @@ describe('the agent-process-source command follows the panel that hosts it', ()
expect(registry.runAction(ACTION_ID)).toBe(true);
});
});
+
+describe('composer model routing', () => {
+ afterEach(() => {
+ cleanup();
+ registry.reset();
+ });
+
+ it('leaves the persisted model to the core for a normal send by default', async () => {
+ mockChatSend.mockClear();
+ await renderChat('text');
+ await submitComposerText('normal default route');
+
+ expect(mockChatSend.mock.calls[0][0]).not.toHaveProperty('model');
+ });
+
+ it('leaves the persisted model to the core for a follow-up send by default', async () => {
+ mockChatSend.mockClear();
+ await renderChat('text', false, true);
+ await submitComposerText('follow-up default route');
+
+ expect(mockChatSend.mock.calls[0][0]).toMatchObject({ queueMode: 'followup' });
+ expect(mockChatSend.mock.calls[0][0]).not.toHaveProperty('model');
+ });
+
+ it('forwards the concrete provider/model chosen in the picker for a normal send', async () => {
+ mockChatSend.mockClear();
+ await renderChat('text');
+
+ await selectPickerModel();
+ await submitComposerText('explicit picker route');
+
+ expect(mockChatSend.mock.calls[0][0]).toMatchObject({ model: 'huggingface:org/model' });
+ });
+
+ it('forwards the concrete provider/model chosen in the picker for a follow-up send', async () => {
+ mockChatSend.mockClear();
+ await renderChat('text', false, true);
+
+ await selectPickerModel();
+ await submitComposerText('explicit follow-up picker route');
+
+ expect(mockChatSend.mock.calls[0][0]).toMatchObject({
+ model: 'huggingface:org/model',
+ queueMode: 'followup',
+ });
+ });
+});
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index f2af22488d..309dea9733 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -1198,7 +1198,7 @@ const Conversations = ({
pendingSendsRef.current.add(sendingThreadId);
addPendingSendingThread(sendingThreadId);
const pendingAttachments = attachments.slice();
- const modelOverride = composerModelOverride ?? CHAT_MODEL_HINT;
+ const modelOverride = composerModelOverride ?? undefined;
const messageText = buildMessageWithAttachments(trimmed, pendingAttachments);
const userMessage: ThreadMessage = {
id: `msg_${globalThis.crypto.randomUUID()}`,
@@ -1271,7 +1271,7 @@ const Conversations = ({
await chatSend({
threadId: sendingThreadId,
message: messageText,
- model: modelOverride,
+ ...(modelOverride !== undefined ? { model: modelOverride } : {}),
locale: uiLocale,
reasoningEffort: composerReasoningEffort,
});
@@ -1328,7 +1328,7 @@ const Conversations = ({
const pendingAttachments = attachments.slice();
if (!normalized && pendingAttachments.length === 0) return;
- const modelOverride = composerModelOverride ?? CHAT_MODEL_HINT;
+ const modelOverride = composerModelOverride ?? undefined;
const messageText = buildMessageWithAttachments(normalized, pendingAttachments);
// Build the full user message exactly like a normal send (content +
// attachment metadata) so the follow-up persists identically when it is
@@ -1370,7 +1370,7 @@ const Conversations = ({
await chatSend({
threadId,
message: messageText,
- model: modelOverride,
+ ...(modelOverride !== undefined ? { model: modelOverride } : {}),
locale: uiLocale,
queueMode: 'followup',
reasoningEffort: composerReasoningEffort,
diff --git a/crates/openhuman-core/src/web_chat/README.md b/crates/openhuman-core/src/web_chat/README.md
index 8fa244a2a2..3808b7b37b 100644
--- a/crates/openhuman-core/src/web_chat/README.md
+++ b/crates/openhuman-core/src/web_chat/README.md
@@ -113,7 +113,7 @@ re-cached its own agent wins.
| `mod.rs` | Module wiring and re-exports; no business logic |
| `ops.rs` (thin shell over `ops/`: `start_chat.rs`, `channel_ops.rs`, `parallel_turn.rs`, `turn_guards.rs`, `state.rs`, `budget_correlation.rs`, `test_hooks.rs`) | `start_chat`/`cancel_*`/`channel_web_*` operations, session cache, in-flight tracking, budget-signal correlation, `run_turn_under_cancel_and_deadline` |
| `run_task.rs` | `run_chat_task`: resolves/builds the session agent, spawns the progress bridge, runs the turn, applies the budget correlation to its error |
-| `session.rs` | Builds/fingerprints the cached session `Agent`, resolves target agent id, locale directive, provider role for a model override |
+| `session.rs` | Builds/fingerprints the cached session `Agent`, resolves target agent id, locale directive, provider role, and turn-local provider/model routing for a model selection |
| `progress_bridge.rs` | Forwards `AgentProgress` into `WebChannelEvent`s and `TurnStateMirror`, emits the `inference_heartbeat` liveness beat |
| `presentation.rs` | `deliver_response` (one unsegmented `chat_done`, persisted first) and `deliver_response_single_bubble` (core-initiated turns); local-model emoji-reaction decision; legacy segmentation helpers |
| `reply_persistence.rs` | Durable write of the reply about to be announced, under a deterministic id shared with the client's own append |
@@ -159,7 +159,11 @@ Namespace `channel`, registered via
progress bridge mirrors turn state here for cross-surface visibility.
- `crate::inference::provider::provider_for_role`: resolves the provider
binding for `provider_role_for_model_override`, which feeds the session
- fingerprint.
+ fingerprint. `effective_session_config` applies a concrete picker provider
+ and model to the per-turn clone; managed `openrouter/...` defaults restore
+ the managed route after restart without saving changes or altering sibling
+ role routes. Hints and unqualified legacy model IDs retain their configured
+ provider route.
- `crate::security::approval::APPROVAL_CHAT_CONTEXT`: scoped by
`run_turn_under_cancel_and_deadline` around the `run_chat_task` future.
`crate::web3::wallet::execution::current_owner()` relies on this task-local
@@ -203,4 +207,5 @@ Namespace `channel`, registered via
`mod.rs` for debug/test builds.
- Per-file unit tests: `event_bus_tests.rs`, `ops_budget_correlation_tests_tests.rs`,
`presentation_tests.rs` + `presentation_test_support_tests.rs`,
- `progress_bridge_tests.rs`, `reply_persistence_tests.rs`, `run_task_tests.rs`.
+ `progress_bridge_tests.rs`, `reply_persistence_tests.rs`, `run_task_tests.rs`,
+ `session_checkout_tests.rs`, `session_routing_tests.rs`.
diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rs
index 57e637fcf1..29e25897b8 100644
--- a/crates/openhuman-core/src/web_chat/session.rs
+++ b/crates/openhuman-core/src/web_chat/session.rs
@@ -71,6 +71,59 @@ pub(crate) fn provider_role_for_model_override(model_override: Option<&str>) ->
}
}
+/// Build the in-memory config for one web-chat turn. Concrete picker values
+/// may include their provider (`ollama:model`, `huggingface:org/model`) while
+/// managed catalog ids use OpenRouter's `openrouter/...` form. The selected
+/// route belongs only to this clone; saved chat settings and sibling workload
+/// roles remain untouched.
+fn effective_session_config(
+ config: &Config,
+ model_override: Option<&str>,
+ temperature: Option<f64>,
+) -> Config {
+ let mut effective = config.clone();
+ if let Some(model) = model_override
+ .map(str::trim)
+ .filter(|model| !model.is_empty())
+ {
+ effective.default_model = Some(model.to_string());
+ }
+
+ // Resolve the effective model even when there was no per-turn override:
+ // persisted defaults must restore their provider after a restart too.
+ if let Some(model) = effective
+ .default_model
+ .as_deref()
+ .map(str::trim)
+ .filter(|model| crate::inference::provider::factory::is_raw_passthrough_model(model))
+ {
+ if model.starts_with("openrouter/") {
+ // The managed backend accepts catalog ids verbatim. This also
+ // clears a stale local/BYOK chat route from the effective clone.
+ effective.chat_provider = Some("openhuman".to_string());
+ } else if let Some((provider, _)) = model.split_once(':') {
+ let provider = provider.trim();
+ let local_route = tinyinference_local::profile::is_local_provider_string(model);
+ let built_in_route = matches!(provider, "claude-code" | "claude_agent_sdk");
+ let configured_cloud_provider = effective
+ .cloud_providers
+ .iter()
+ .any(|entry| entry.slug.eq_ignore_ascii_case(provider));
+ if local_route || built_in_route || configured_cloud_provider {
+ // Provider strings use the same `<slug>:<model>` grammar as
+ // the normal inference factory; keep the full selection so
+ // model ids containing additional colons remain intact.
+ effective.chat_provider = Some(model.to_string());
+ }
+ }
+ }
+
+ if let Some(temp) = temperature {
+ effective.default_temperature = temp;
+ }
+ effective
+}
+
pub(super) fn build_session_agent(
config: &Config,
client_id: &str,
@@ -80,14 +133,8 @@ pub(super) fn build_session_agent(
temperature: Option<f64>,
locale: Option<&str>,
) -> Result<OpenHumanSessionHost, String> {
- let mut effective = config.clone();
- if let Some(model) = model_override {
- effective.default_model = Some(model);
- }
+ let effective = effective_session_config(config, model_override.as_deref(), temperature);
let provider_role = provider_role_for_model_override(effective.default_model.as_deref());
- if let Some(temp) = temperature {
- effective.default_temperature = temp;
- }
log::info!(
"[web-channel] routing chat turn to '{}' provider_role='{}' (client_id={}, thread_id={})",
@@ -258,10 +305,11 @@ pub(super) fn build_session_fingerprint(
target_agent_id: String,
provider_role: &str,
) -> SessionCacheFingerprint {
+ let effective = effective_session_config(config, model_override.as_deref(), temperature);
SessionCacheFingerprint {
model_override,
temperature,
- provider_binding: crate::inference::provider::provider_for_role(provider_role, config),
+ provider_binding: crate::inference::provider::provider_for_role(provider_role, &effective),
target_agent_id,
autonomy_signature: autonomy_signature(config),
model_registry_signature: model_registry_signature(config),
@@ -316,7 +364,8 @@ pub(crate) async fn checkout_session_agent(
) -> Result<CheckedOutSession, String> {
let map_key = super::ops::key_for(thread_id);
let target_agent_id = pick_target_agent_id(config);
- let provider_role = provider_role_for_model_override(model_override.as_deref());
+ let effective = effective_session_config(config, model_override.as_deref(), temperature);
+ let provider_role = provider_role_for_model_override(effective.default_model.as_deref());
let fingerprint = build_session_fingerprint(
config,
model_override.clone(),
@@ -451,3 +500,7 @@ pub(crate) async fn checkin_session_agent_if_vacant(
#[cfg(test)]
#[path = "session_checkout_tests.rs"]
mod session_checkout_tests;
+
+#[cfg(test)]
+#[path = "session_routing_tests.rs"]
+mod session_routing_tests;
diff --git a/crates/openhuman-core/src/web_chat/session_routing_tests.rs b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
new file mode 100644
index 0000000000..e32005247c
--- /dev/null
+++ b/crates/openhuman-core/src/web_chat/session_routing_tests.rs
@@ -0,0 +1,244 @@
+use super::effective_session_config;
+use crate::config::Config;
+use crate::inference::provider::provider_for_role;
+
+fn with_huggingface_route(config: &mut Config) {
+ config
+ .cloud_providers
+ .push(crate::config::schema::CloudProviderCreds {
+ id: "huggingface-test".to_string(),
+ slug: "huggingface".to_string(),
+ label: "Hugging Face test route".to_string(),
+ endpoint: "https://huggingface.co".to_string(),
+ ..Default::default()
+ });
+}
+
+#[test]
+fn picker_routes_follow_provider_and_model_across_turns() {
+ let mut original = Config::default();
+ original.chat_provider = Some("openai:gpt-4o".to_string());
+ original.reasoning_provider = Some("anthropic:claude-sonnet".to_string());
+ original.coding_provider = Some("openai:o3-mini".to_string());
+ with_huggingface_route(&mut original);
+ let original_snapshot = serde_json::to_value(&original).expect("config serializes");
+
+ let mut selected = effective_session_config(
+ &original,
+ Some("openrouter/author/managed-model:free"),
+ None,
+ );
+ assert_eq!(
+ provider_for_role("chat", &selected),
+ "openhuman",
+ "managed catalog selection replaces a prior BYOK route"
+ );
+ assert_eq!(
+ selected.default_model.as_deref(),
+ Some("openrouter/author/managed-model:free")
+ );
+
+ selected = effective_session_config(&selected, Some("ollama:gpt-oss:120b-cloud"), None);
+ assert_eq!(
+ provider_for_role("chat", &selected),
+ "ollama:gpt-oss:120b-cloud",
+ "local picker selection retains the model suffix after the provider colon"
+ );
+ assert_eq!(
+ selected.default_model.as_deref(),
+ Some("ollama:gpt-oss:120b-cloud")
+ );
+
+ selected = effective_session_config(&selected, Some("ollama:qwen3:4b-instruct"), None);
+ assert_eq!(
+ provider_for_role("chat", &selected),
+ "ollama:qwen3:4b-instruct"
+ );
+
+ selected = effective_session_config(&selected, Some("huggingface:org/model"), None);
+ assert_eq!(
+ provider_for_role("chat", &selected),
+ "huggingface:org/model"
+ );
+
+ selected = effective_session_config(
+ &selected,
+ Some("openrouter/author/managed-model:free"),
+ None,
+ );
+ assert_eq!(
+ provider_for_role("chat", &selected),
+ "openhuman",
+ "managed selection clears a previously selected local or cloud route"
+ );
+
+ assert_eq!(
+ serde_json::to_value(&original).expect("config serializes"),
+ original_snapshot,
+ "turn selections must not mutate the saved config"
+ );
+ assert_eq!(
+ provider_for_role("reasoning", &selected),
+ "anthropic:claude-sonnet",
+ "changing the chat picker must not change sibling workload routes"
+ );
+ assert_eq!(provider_for_role("coding", &selected), "openai:o3-mini");
+}
+
+#[test]
+fn persisted_managed_default_restores_managed_route_after_restart() {
+ let mut persisted = Config::default();
+ persisted.default_model = Some("openrouter/author/restored-model:free".to_string());
+ persisted.chat_provider = Some("ollama:qwen3:4b-instruct".to_string());
+
+ let effective = effective_session_config(&persisted, None, None);
+ assert_eq!(
+ effective.default_model.as_deref(),
+ Some("openrouter/author/restored-model:free")
+ );
+ assert_eq!(provider_for_role("chat", &effective), "openhuman");
+ assert_eq!(
+ persisted.chat_provider.as_deref(),
+ Some("ollama:qwen3:4b-instruct"),
+ "restoration is turn-local and leaves persisted routing alone"
+ );
+}
+
+#[test]
+fn persisted_local_default_restores_its_route_after_restart() {
+ let mut persisted = Config::default();
+ persisted.default_model = Some("ollama:qwen3:4b-instruct".to_string());
+ persisted.chat_provider = Some("openai:gpt-4o".to_string());
+
+ let effective = effective_session_config(&persisted, None, None);
+ assert_eq!(
+ effective.default_model.as_deref(),
+ Some("ollama:qwen3:4b-instruct")
+ );
+ assert_eq!(
+ provider_for_role("chat", &effective),
+ "ollama:qwen3:4b-instruct"
+ );
+}
+
+#[test]
+fn hints_and_legacy_model_ids_keep_the_configured_route() {
+ let mut config = Config::default();
+ config.default_model = Some("stored-default".to_string());
+ config.chat_provider = Some("openai:gpt-4o".to_string());
+ config.coding_provider = Some("ollama:qwen3-coder:latest".to_string());
+ let original = config.clone();
+
+ let hint = effective_session_config(&config, Some("hint:coding"), None);
+ assert_eq!(
+ provider_for_role("coding", &hint),
+ "ollama:qwen3-coder:latest"
+ );
+ assert_eq!(provider_for_role("chat", &hint), "openai:gpt-4o");
+
+ let legacy_alias = effective_session_config(&config, Some("coding-v1"), None);
+ assert_eq!(
+ provider_for_role("coding", &legacy_alias),
+ "ollama:qwen3-coder:latest"
+ );
+
+ let unqualified = effective_session_config(&config, Some("gpt-4.1-mini"), None);
+ assert_eq!(provider_for_role("chat", &unqualified), "openai:gpt-4o");
+ assert_eq!(unqualified.default_model.as_deref(), Some("gpt-4.1-mini"));
+
+ for selection in [
+ "claude-code:claude-sonnet-4-20250514",
+ "claude_agent_sdk:claude-sonnet-4-20250514",
+ ] {
+ let built_in = effective_session_config(&config, Some(selection), None);
+ assert_eq!(
+ provider_for_role("chat", &built_in),
+ selection,
+ "built-in provider route {selection} is recognized without a cloud provider entry"
+ );
+ }
+
+ assert_eq!(config.default_model, original.default_model);
+ assert_eq!(config.chat_provider, original.chat_provider);
+ assert_eq!(config.coding_provider, original.coding_provider);
+}
+
+#[test]
+fn explicit_picker_override_wins_over_a_different_persisted_default() {
+ let mut persisted = Config::default();
+ persisted.default_model = Some("openrouter/author/old-model:free".to_string());
+ persisted.chat_provider = Some("openhuman".to_string());
+
+ let effective = effective_session_config(&persisted, Some("ollama:gpt-oss:120b-cloud"), None);
+ assert_eq!(
+ effective.default_model.as_deref(),
+ Some("ollama:gpt-oss:120b-cloud")
+ );
+ assert_eq!(
+ provider_for_role("chat", &effective),
+ "ollama:gpt-oss:120b-cloud"
+ );
+}
+
+#[test]
+fn session_fingerprint_records_the_effective_picker_route() {
+ let mut config = Config::default();
+ config.chat_provider = Some("ollama:qwen3:4b-instruct".to_string());
+
+ let managed = super::build_session_fingerprint(
+ &config,
+ Some("openrouter/author/model:free".to_string()),
+ None,
+ "orchestrator".to_string(),
+ "chat",
+ );
+ let local = super::build_session_fingerprint(
+ &config,
+ Some("ollama:gpt-oss:120b-cloud".to_string()),
+ None,
+ "orchestrator".to_string(),
+ "chat",
+ );
+
+ assert_eq!(managed.provider_binding, "openhuman");
+ assert_eq!(local.provider_binding, "ollama:gpt-oss:120b-cloud");
+ assert_ne!(managed.provider_binding, local.provider_binding);
+}
+
+#[test]
+fn unknown_qualified_models_keep_the_existing_route() {
+ let mut config = Config::default();
+ config.chat_provider = Some("openai:gpt-4o".to_string());
+
+ 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"
+ );
+ assert_eq!(
+ effective.default_model.as_deref(),
+ Some("unknown-provider:some-model"),
+ "unknown legacy model values still pass through as the model override"
+ );
+}
+
+#[test]
+fn selected_ollama_route_constructs_the_selected_model_without_network() {
+ let mut config = Config::default();
+ config.chat_provider = Some("openhuman".to_string());
+ config.local_ai.base_url = Some("http://127.0.0.1:1".to_string());
+
+ for model in ["gpt-oss:120b-cloud", "qwen3:4b-instruct"] {
+ let selection = format!("ollama:{model}");
+ 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("local model construction requires no provider request");
+ assert_eq!(resolved_model, model);
+ }
+}
diff --git a/docs/RELEASE-MANUAL-SMOKE.md b/docs/RELEASE-MANUAL-SMOKE.md
index a8b05880e8..75f22f2367 100644
--- a/docs/RELEASE-MANUAL-SMOKE.md
+++ b/docs/RELEASE-MANUAL-SMOKE.md
@@ -130,3 +130,5 @@ Notes:
```
Paste the filled block as a commit comment on the `v<version>-staging` tagged commit before promoting to production.
+
+- [ ] **Chat model picker selects the provider as well as the model (#6938)** — In an isolated test profile, switch the same thread from managed to Ollama, then to a configured BYOK provider, and back to a managed catalog model (including a `:free` variant). Verify the actual request endpoint and model match each selection, configured background routes stay unchanged, and reopening the app restores the selected provider/model. Selecting a workload hint must retain its configured route.
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 7f393a82ec..ae1a5256e4 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -597,7 +597,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an
| 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 | PW | `app/test/playwright/specs/chat-model-managed-catalog.spec.ts` (`a composer pick is the global default and survives a fresh page`) | 🟡 | **Was ✅ against a spec that does not run**: `chat-model-managed-catalog.spec.ts:142` is `test.describe.skip` with `TODO(#6395): rebuild these assertions around the picker’s native model select`. The claim is unasserted at every layer until #6395 lands. 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. |
+| 13.3.10 | Composer model pick is the global default | PW | `app/test/playwright/specs/chat-model-managed-catalog.spec.ts` (`a composer pick is the global default and survives a fresh page`) | 🟡 | **Was ✅ against a spec that does not run**: `chat-model-managed-catalog.spec.ts:142` is `test.describe.skip` with `TODO(#6395): rebuild these assertions around the picker’s native model select`. The claim is unasserted at every layer until #6395 lands. 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 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`); these checks do not replace the skipped picker UI assertion. |
| 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