#10186: fix: clear model/provider override when /new starts a fresh session
commands
stale
Cluster:
Session Management Improvements
## Summary
- When using `/new` to start a fresh session, the model override from the previous session was carried over
- Root cause: the skills-snapshot persistence path in `agent.ts` uses `...current` to spread the previous `SessionEntry`, which includes `modelOverride` and `providerOverride`
- Fix: explicitly set `modelOverride` and `providerOverride` to `undefined` when `isNewSession` is true
- Repro: set default model to MiniMax → switch to Opus via `/opus` → send `/new` → session stays on Opus instead of reverting to MiniMax
Closes #10107
## Test plan
- [x] Verified the spread operator at line 207 (`...current`) copies all fields from the old session entry
- [x] The new conditional spread clears overrides only when `isNewSession` is true, leaving normal session updates unaffected
- [x] Existing session fields (skillsSnapshot, sessionId, updatedAt) are preserved correctly
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `src/commands/agent.ts` so that when `/new` starts a fresh session, any persisted `modelOverride` / `providerOverride` from the prior session are explicitly cleared while persisting the new session’s `skillsSnapshot`. This prevents model/provider selections made via `/opus`-style commands from leaking into the next “fresh” session, restoring the configured defaults.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is narrowly scoped to session persistence on new-session creation and uses the existing session store write path; no behavioral changes occur for non-new sessions. Clearing overrides via explicit `undefined` prevents them from being re-selected on subsequent model resolution.
- src/commands/agent.ts
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#21849: fix(session): clear model/provider overrides on /new and /reset
by widingmarcus-cyber · 2026-02-20
84.1%
#21847: fix(session): /new and /reset no longer carry over model overrides
by hydro13 · 2026-02-20
82.9%
#21876: fix(session): clear model override on /new and /reset
by sauerdaniel · 2026-02-20
80.6%
#17011: fix(/new /reset): clear model override for reset turn
by Limitless2023 · 2026-02-15
80.3%
#13376: fix: pass model directly to agent for sub-agent runs
by jrbobbyhansen-pixel · 2026-02-10
79.5%
#17414: fix(sessions): refresh contextTokens when model override changes
by michaelbship · 2026-02-15
78.7%
#19328: Fix: preserve modelOverride in agent handler (#5369)
by CodeReclaimers · 2026-02-17
78.7%
#6603: fix: use allowAny flag instead of size check for model override val...
by gavinbmoore · 2026-02-01
78.5%
#21731: Fix: clear stale session runtime model on /new, /reset, and session...
by AIflow-Labs · 2026-02-20
78.3%
#9822: fix: allow local/custom model providers for sub-agent inference
by stammtobias91 · 2026-02-05
78.2%