Repository navigation
fix(control-ui): preserve configured model metadata in picker - #61382
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f95733b447
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return resolveServerChatModelValue(trimmedModel, trimmedProvider); | ||
| } | ||
|
|
||
| return qualifiedServerValue; |
There was a problem hiding this comment.
Keep fully qualified model refs when catalog lookup fails
When resolvePreferredServerChatModelValue receives a slash-containing model plus a provider but no catalog match (for example, models.list failed and returned []), it now falls through to qualifiedServerValue and prepends the provider again. In the stale-provider case this rewrites an already-qualified ref like openai/gpt-5-mini into zai/openai/gpt-5-mini, which changes model identity and can propagate into cached override/tools keys until a later refresh. The previous behavior preserved the already-qualified value in this fallback path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
leaving this open for now since the fallback is ambiguous without better catalog context.
Greptile SummaryThis PR fixes the Control UI model picker losing configured model metadata and nested model refs jumping to the wrong provider after refresh. The gateway now propagates configured Confidence Score: 5/5Safe to merge; all findings are P2 style/DRY nits with no functional impact. No P0 or P1 issues found. The fix is well-scoped, well-reasoned, and backed by new unit and integration tests across gateway normalization, session utils, and UI picker layers. No files require special attention; the two P2 observations in Prompt To Fix All With AIThis is a comment left during a code review.
Path: ui/src/ui/chat-model-select-state.ts
Line: 100-110
Comment:
**`buildCatalogDisplayLookup` called twice on the same catalog**
`buildCatalogDisplayLookup(catalog)` is computed here at line 100, and then again inside `buildChatModelOptions` at line 64 (called at line 110 with the same `catalog` reference). The O(n) pass is redundant. Pass the already-built `displayLookup` into `buildChatModelOptions` as a parameter to eliminate the duplicate work and make the data-flow explicit.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/live-model-switch.ts
Line: 15-28
Comment:
**Duplicate provider-prefix normalization logic**
`normalizeStoredOverrideSelection` here and `normalizeStoredSessionOverride` in `src/gateway/session-utils.ts` (lines 1021–1041) implement near-identical prefix-stripping logic. If this normalization ever needs to change (e.g. to handle provider-ID casing edge cases), it will need updating in two places. Extracting a shared helper in a utility module would prevent future drift.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "test(control-ui): cover model picker res..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65ccc81f98
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09632be7c8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return resolveServerChatModelValue(trimmedModel, trimmedProvider); | ||
| } | ||
|
|
||
| return qualifiedServerValue; |
There was a problem hiding this comment.
Preserve qualified model when catalog lookup is unavailable
When resolvePreferredServerChatModelValue gets an already-qualified model (contains /) and a stale provider, the empty-catalog fallback returns qualifiedServerValue from the stale provider. In the models.list failure path (loadModelCatalog(..., { allowFailure: true }) returns []), this rewrites values like openai/gpt-5-mini into zai/openai/gpt-5-mini, changing model identity and affecting cached override/effective-tools keys after /model. This fallback should keep the original qualified value unless catalog evidence says otherwise.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
leaving this open for now since the fallback is ambiguous without better catalog context.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac42ad16d6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return resolveServerChatModelValue(trimmedModel, trimmedProvider); | ||
| } | ||
|
|
||
| return qualifiedServerValue; |
There was a problem hiding this comment.
Preserve qualified model refs when catalog fallback is empty
resolvePreferredServerChatModelValue can rewrite an already-qualified model to the wrong identity when catalog lookup fails. In the reachable allowFailure path (loadModelCatalog(..., { allowFailure: true }) in ui/src/ui/chat/slash-command-executor.ts), an input like openai/gpt-5-mini with a stale provider can fall through to qualifiedServerValue and return zai/openai/gpt-5-mini, which changes the selected model and downstream cache/tool-resolution keys even though no catalog evidence supports that rewrite.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
leaving this open for now since the fallback is ambiguous without better catalog context.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27243f6e6a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const qualifiedServerValue = buildQualifiedChatModelValue(trimmedModel, trimmedProvider); | ||
| if (hasCatalogQualifiedValue(catalog, qualifiedServerValue)) { | ||
| return qualifiedServerValue; |
There was a problem hiding this comment.
Match slash model IDs against catalog before prefixing provider
For slash-containing server models, this branch prepends trimmedProvider before checking whether the catalog has a unique match by entry.id, so a stale provider can still overwrite model identity even when catalog evidence exists. Example: model="moonshotai/kimi-k2.5", provider="zai", and catalog entry { provider: "nvidia", id: "moonshotai/kimi-k2.5" } returns zai/moonshotai/kimi-k2.5 instead of the catalog-backed provider. Fresh evidence beyond prior comments: this mis-resolution happens even with a non-empty catalog, because the current lookup only compares fully-qualified keys.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3b8db9b212 by matching slash-containing model ids against catalog entry.id before falling back to the server provider.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b8db9b212
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| return qualifiedServerValue; |
There was a problem hiding this comment.
Preserve qualified refs on server-provider fallback
When model already includes a provider segment and catalog lookup cannot confirm a match, this fallback returns qualifiedServerValue, which is built by prepending the server-reported provider to trimmedModel. With stale provider metadata (for example model="openai/gpt-5-mini", provider="zai"), the function emits zai/openai/gpt-5-mini instead of preserving the original ref, so /model can cache and reuse a wrong model identity for tools-effective/session overrides until a later refresh. Fresh evidence beyond earlier thread context: this same rewrite happens not only on empty catalogs, but also when the catalog is non-empty yet missing the exact qualified key.
Useful? React with 👍 / 👎.
3b8db9b to
b1c0241
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1c0241b3e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| !resolvedValue.toLowerCase().startsWith(`${resolvedProvider.toLowerCase()}/`) && | ||
| requestedOverride.value.toLowerCase().endsWith(`/${resolvedModel.trim().toLowerCase()}`) | ||
| ) { | ||
| resolvedValue = requestedOverride.value; |
There was a problem hiding this comment.
Preserve catalog-corrected provider for qualified /model updates
This fallback rewrites resolvedValue back to the user-requested qualified string whenever the suffix matches resolvedModel, even when catalog resolution already found a different canonical provider. In practice, a qualified request like z-ai/deepseek-chat can end up caching z-ai/deepseek-chat instead of the catalog-backed deepseek/deepseek-chat, which makes the local sessionPatch.modelOverride diverge from gateway/model-catalog normalization and can skew subsequent UI model state and tools-effective keys until a full refresh.
Useful? React with 👍 / 👎.
7e474e2 to
dd5f2ec
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd5f2ec245
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| modelOverride: modelOverride.toLowerCase().startsWith(providerPrefix) | ||
| ? modelOverride.slice(providerOverride.length + 1).trim() || modelOverride | ||
| : modelOverride, |
There was a problem hiding this comment.
Avoid stripping real nested model prefixes from overrides
normalizeStoredOverrideModel removes any leading providerOverride + "/" from modelOverride, which breaks valid nested IDs that intentionally start with that segment (for example, provider nvidia with model ID nvidia/nemotron-...). After this commit, both resolveSessionModelRef and live-switch resolution pass through this helper, so persisted overrides for those models are rewritten to a different model key on read, leading to wrong model selection after refresh/restart.
Useful? React with 👍 / 👎.
dd5f2ec to
ba5b5e0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba5b5e08e4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| modelOverride: modelOverride.toLowerCase().startsWith(providerPrefix) | ||
| ? modelOverride.slice(providerOverride.length + 1).trim() || modelOverride |
There was a problem hiding this comment.
Preserve provider-prefixed nested override IDs
Do not strip providerOverride + "/" unconditionally here: it rewrites valid model IDs that intentionally begin with that segment (for example providerOverride="nvidia" with modelOverride="nvidia/nemotron-..."). After this normalization, both resolveSessionModelRef and live-switch resolution interpret the override as a different model (nemotron-...), so persisted sessions can silently select the wrong model after reload/restart.
Useful? React with 👍 / 👎.
| !resolvedValue.toLowerCase().startsWith(`${resolvedProvider.toLowerCase()}/`) && | ||
| requestedOverride.value.toLowerCase().endsWith(`/${resolvedModel.trim().toLowerCase()}`) | ||
| ) { | ||
| resolvedValue = requestedOverride.value; |
There was a problem hiding this comment.
Keep catalog-canonical provider in /model cache patch
Avoid overriding the normalized resolvedValue with requestedOverride.value in this fallback. When sessions.patch reports a stale/non-canonical provider but catalog resolution found the canonical qualified model, this branch writes the stale requested provider back into sessionPatch.modelOverride (for example z-ai/deepseek-chat instead of deepseek/deepseek-chat), causing local picker state and tools-effective cache keys to diverge from catalog-backed model identity until a later refresh.
Useful? React with 👍 / 👎.
|
Merged via squash.
Thanks @Mule-ME! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c738f6f146
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| return { | ||
| ...params.entry, | ||
| name: configuredEntry?.name ?? params.entry.name, |
There was a problem hiding this comment.
Avoid clobbering discovered names with implicit config defaults
applyModelCatalogMetadata always sets name from configuredEntry when one exists, but buildConfiguredModelCatalog gives every configured model a fallback name equal to its id when no explicit name was configured. That means id-only provider configs now overwrite discovered friendly names (for example, replacing GPT-4o with gpt-4o) even though the user did not specify a custom name, regressing picker labels and model metadata quality for common configurations.
Useful? React with 👍 / 👎.
Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
…aw#61382) Merged via squash. Prepared head SHA: c738f6f Co-authored-by: Mule-ME <[email protected]> Co-authored-by: mukhtharcm <[email protected]> Reviewed-by: @mukhtharcm
Summary
model-id · providerlabels instead of configured aliases/names, and models likenvidia/moonshotai/kimi-k2.5could jump to the wrong provider after refresh.alias/namemetadata in the catalog, session and live-switch normalization preserve nested provider/model refs, and the Control UI picker now prefersalias || name || raw.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
aliaswas not exposed in the catalog contract, and session override normalization did not preserve nested provider/model refs consistently across refresh paths./modelcaching path for nested ids.git blame, prior PR, issue, or refactor if known): reported in Bug: Control UI Model Display and Selection Issues #58835; an earlier UI-only attempt in fix(control-ui): use catalog names in model picker #59831 improved display but still pushed too much identity repair into the frontend.Regression Test Plan (if applicable)
src/agents/model-selection.test.tssrc/gateway/session-utils.test.tssrc/agents/live-model-switch.test.tssrc/gateway/server.models-voicewake-misc.test.tssrc/gateway/server.sessions.gateway-server-sessions-a.test.tsui/src/ui/chat-model-ref.test.tsui/src/ui/chat-model-select-state.test.tsui/src/ui/chat/slash-command-executor.node.test.tsui/src/ui/controllers/agents.test.tsalias/namepropagate intomodels.listalias || name || raw/modelcaching preserves nested refs when catalog lookup is present or unavailableUser-visible / Behavior Changes
nvidia/moonshotai/kimi-k2.5stay provider-qualified after refresh./modelupdates and tools-effective resolution now use the same normalized model identity.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
main, built-in Control UInvidia/moonshotai/kimi-k2.5and other catalog-backed modelsnameplusagents.defaults.modelsaliasesSteps
nvidia/moonshotai/kimi-k2.5.Expected
model-id · provider.Actual
Evidence
Attach at least one:
Before: raw provider/model labels in the picker.

After: friendly alias/name labels from the catalog.

Human Verification (required)
/modeland tools-effective paths use the normalized refReview Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
/model, tools-effective resolution, and picker rendering.