Repository navigation
fix(native-chat): never adopt an unlisted model as the launch default - #19854
Conversation
`modelIsAdoptableAsLaunchDefault` is the sole gate on whether a model id may become the persisted `-m` launch flag for future native chats. For a catalog that does not set `discoveredModelsAreAuthoritative` — Claude and Codex — `!catalog.discoveredModelsAreAuthoritative` short-circuited the discovered branch to `true` for any id at all. So a raw launch flag (`worker-start --model claude-opus-5`) is seeded verbatim into the session record, and the first option write or model re-pick adopted it as the durable default. Every later native chat with that agent then launched `-m claude-opus-5` — an id neither the host CLI's list nor the catalog seed carries. Both branches now sit behind one precondition: the active model list or the catalog seed must carry the id. Ids that are carried keep their existing behaviour, including the authoritative-retirement and tracked-model rules.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to Launch-default model adoption now avoids persisting unlisted model IDs while retaining the documented valid catalog and discovery cases. No current merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed bug, fix, scope, and test information, but it does not follow the repository template. It omits the required ELI5, Linked Issue, Visual Proof, Testing checklist, AI Disclosure, Review, boundary, Notes, and Checklist sections. Resolution Add all required template sections. Include the linked issue after “Fixes #”, write
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…y vector A typed `/model` cannot introduce an unlisted id: matchNativeChatCatalogModelId returns only ids drawn from the list it is handed, so a never-seen id either collapses to a catalog id (claude `/model claude-opus-5` -> `opus`) or matches nothing (codex). It can only re-assert an id already in the record. The origins that do enter verbatim are the launch flag and an agent report -- applyNativeChatReportedSessionOptions writes `values.model` with no catalog matching. Say that instead, so the comment is true of the code as written and does not lean on the reconciled row that #19852 removes. Comment only; no behaviour change.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Launch-default adoption gate narrowed —
modelIsAdoptableAsLaunchDefaultnow requires the id to be carried by the activemodelslist or thecatalog.modelsseed before either branch may adopt it, so an id only a raw launch flag or typed/modelnamed can no longer become the persisted-mdefault. - Regression and no-regression coverage added — five tests in
native-chat-launch-default-adoption.test.tspin the two unlisted-id negatives (both RED under the old code) and the three seed/host-catalog still-adopted guards.
The narrowing is a pure && gate on top of the existing branches: grok's authoritative path still requires listedIn(models), and codex/gemini never reach persist (their options are all agent-picker), so neither the authoritative retirement flow nor codex's "unknown persisted ids pass through" seed contract regresses. The new and existing suites pass (38 passed).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Precondition doc comment corrected — commit
715a3bbrewrites themodelIsAdoptableAsLaunchDefaultcomment to state the two verbatim entry paths accurately (raw launch flag and agent report) and drops the misleading "typed/model" wording, which the PR body correctly notes is not a third path.
The only change since the prior review is this comment edit; the gate logic and the five tests are unchanged. Verified against the updated PR body: matchNativeChatCatalogModelId only returns ids drawn from the list it is handed, so a typed /model can only re-assert an id already tracked by a launch flag or an agent report — the revised comment matches that contract.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status: landNo in-scope issues remain at
|


The bug
modelIsAdoptableAsLaunchDefaultinnative-chat-pty-session-options.tsis the sole gate on whether a model id may become the persisted-mlaunch flag for future native chats with an agent:Claude and Codex do not set
discoveredModelsAreAuthoritative, so!catalog.discoveredModelsAreAuthoritativeistrueand the discovered branch short-circuits totruefor any id once a host model list has arrived.How an unlisted id gets into the record
Two paths write a model id verbatim, with no catalog matching:
worker-start --model claude-opus-5flows throughseedNativeChatAppliedSessionOptions, which storesvalues.modelas-is.applyNativeChatReportedSessionOptions(native-chat-session-option-state.ts:132-138) likewise storesvalues.modelas-is, so an agent reporting a model name Orca does not carry lands one too.A typed
/modelis not a third path:matchNativeChatCatalogModelIdonly ever returns ids drawn from the list it is handed, so a never-seen id either collapses to a catalog id (claude/model claude-opus-5→opus) or matches nothing (codex/model gpt-6-turbo→ no persist). It can only re-assert an id one of the two paths above already tracked.User-visible consequence
Once such an id is in the record, the first option write or model re-pick in that chat persists it as the durable default, and every future native chat with that agent launches
-m claude-opus-5— an id that neither the host CLI's list nor the catalog seed carries. The same holds for the pre-discovery branch, where a tracked model is treated as proof enough; tracking only says the id was written, not that it names a real model.The fix
Both branches now sit behind one precondition: the active
modelslist or thecatalog.modelsseed must carry the id. An id no list carries is not evidence of anything and never becomes durable state.Ids that are carried keep every existing behaviour — the change is a pure
&&narrowing:models.some(...), and the precondition is implied by it.opuswhen the CLI lists onlyopus[1m]) is still adopted — it is a real model the seed vouches for.opus[1m], unseeded) is still adopted.record.model !== undefinedbranch is otherwise untouched.The gate reads the raw
modelsandcatalog.modelslists, never the reconciledactiveModels(), so it does not depend on the fabricated row and is correct both before and after #19852.Tests
New file
native-chat-launch-default-adoption.test.ts(5 tests). The new tests went in their own file becausenative-chat-pty-session-options.test.tsis already near the 800-linemax-linescap and adding to it broke the rule; no suppression was added, and that file is restored to a verified-empty diff.Ablation — production change reverted by hand, restored by hand, re-proven at the final commit:
The three no-regression guards cannot go red against this change by construction, so each was also proven load-bearing against an over-reaching variant of the fix: dropping the seed fallback reddens the seeded-alias test; a seed-only precondition reddens the host-catalog test and an existing grok test; neutering the pre-discovery branch reddens the tracked-seed test and two existing tests.
Not in this PR
{ id, label: id, options: [] }catalog row — that is Name a native-chat model only when it is available or agent-reported #19852, already open.worker-start --modelitself behaves exactly as onmain; nothing undersrc/main/runtime/rpc/methods/orchestration/is touched.