fix(api): honor the Chat task preset for local API / MCP chat - #730
Open
johnsonafool wants to merge 1 commit into
Open
fix(api): honor the Chat task preset for local API / MCP chat#730johnsonafool wants to merge 1 commit into
johnsonafool wants to merge 1 commit into
Conversation
`load_agent_runtime_config` only looked at the project override and the global `llmConfig`, ignoring `taskModelRouting.chatPresetId`. With the common setup "Ingest: Claude Code CLI, Chat: Azure / OpenAI", every chat through the local HTTP API (and therefore the MCP server) resolved to the CLI provider, which the backend HTTP agent cannot drive, and degraded to the retrieval-only fallback answer. Resolve the Chat preset the same way `resolveTaskLlmConfig` does in src/lib/llm-task-routing.ts: enabled project override -> Chat preset from `providerConfigs` (built-in ids and `custom-*` presets) -> global `llmConfig`. Presets the backend cannot use (claude-code, codex-cli, missing key/model) yield None so behaviour is unchanged for them. Verified on Windows (0.6.11 desktop): with Chat = Azure gpt-4o, the API chat went from dumping search hits to a synthesized answer with citations. Unit test covers built-in, CLI, custom, unknown/deleted presets and the project-override precedence. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
johnsonafool
added a commit
to johnsonafool/llm_wiki
that referenced
this pull request
Sep 6, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the desktop app is configured with different models per task — the very common setup Ingest: Claude Code CLI, Chat: Azure / OpenAI — every chat that goes through the local HTTP API (
POST /api/v1/projects/{id}/chat) and therefore through the bundled MCP server ignores the Chat routing.load_agent_runtime_configinapi_server.rsonly looks at the enabled project override and the globalllmConfig, so it resolves to the CLI provider, which the backend HTTP agent cannot drive (is_usable_for_backend_http→ false), and the turn degrades to the retrieval-only fallback answer ("I searched the current LLM Wiki project for … and found N relevant page(s)").The desktop UI does not hit this because the frontend resolves the preset itself (
resolveTaskLlmConfig) before calling the runtime.Fix
Resolve the Chat task preset on the backend with the same precedence the frontend uses:
taskModelRouting.chatPresetId→providerConfigs[presetId], mapped ontoLlmConfig(built-in preset ids with their default endpoints / API modes,custom-*presets validated againstcustomLlmPresets)llmConfig(unchanged behaviour)Presets the backend cannot use (claude-code, codex-cli, missing key or model) return
None, so nothing changes for them.Verified
gpt-4o, ingest = Claude Code CLI. Before: API chat returned the search-hit dump withtoolEventsonly. After: a synthesized answer with citations in ~4 s.chat_preset_routes_api_chat_to_the_selected_providercovers: built-in preset (Azure), CLI preset →None, known custom preset defaults (DeepSeek), unknown / deleted custom presets →None, and disabled project override yielding to the Chat preset.Notes for review
BUILTIN_LLM_PRESETS) duplicates the ids/defaults fromsrc/components/settings/llm-presets.ts. If you would rather have the frontend persist a resolved, non-secret chat profile (the wayprojectLlmOverrides[].profilealready works) and merge credentials at runtime, I'm happy to rework it that way — this version is the smallest change that makes MCP/API chat follow the user's routing.