Commit 37d8793
a.dmitriev
fix(mcp): match language model by provider+model with precise error messages
The MCP package (@sourcebot/mcp) omits displayName from the ask_codebase
request schema (.omit({ displayName: true })), so LLM agents can only
pass {provider, model}. The previous getLanguageModelKey-based match
included displayName in the key, causing a permanent 400 for any explicit
model selection.
New matching logic:
- filter configured models by provider+model to collect candidates
- displayName check uses !== undefined (not truthiness) so "" is treated
as an explicit value, not absent
- if displayName provided: exact match within candidates — preserves
disambiguation between same-model entries with different displayName
(e.g. two opus-4-7 with different reasoningEffort)
- if displayName absent and exactly one candidate: use it
- if displayName absent and multiple candidates: return 400 with hint
Three distinct 400 messages:
- provider+model not found: "Language model 'X/Y' is not configured."
- displayName mismatch: "… is configured but displayName 'Z' was not
found. Available: "A", "B"."
- ambiguous: "Multiple configurations found for 'X/Y'. Provide a
displayName to disambiguate. Available: "A", "B"."
Available displayNames are quoted and filtered so undefined values never
appear in error messages.
Also removes the now-unused getLanguageModelKey import.
Fixes #11371 parent 105ddf4 commit 37d8793
1 file changed
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
64 | 84 | | |
65 | 85 | | |
66 | 86 | | |
67 | | - | |
| 87 | + | |
68 | 88 | | |
69 | 89 | | |
70 | 90 | | |
| |||
0 commit comments