#17375: fix(session): don't carry stale model info into reset welcome message
channel: mattermost
gateway
size: XS
Cluster:
Session Management Improvements
## Summary
After `/new` or `/reset`, the welcome message displayed a stale model name from the previous session's cached `model` and `contextTokens` fields — confusing users with wrong model info. Fixed by stopping the carry-over of `model` and `contextTokens` from the old session during resets.
Fixes #17003
## Validation
- [x] `pnpm build` — passed
- [x] `pnpm check` (format + tsgo + lint) — passed
- [x] `pnpm test` — 1073 tests passed (105 test files)
## Scope
- Single focused fix — single file changed (`src/gateway/server-methods/sessions.ts`)
## AI-Assistance
- AI-assisted (Claude Code) for implementation
- Human-reviewed: confirmed understanding of changes
- Testing: full local validation suite passed
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes a bug where `/new` or `/reset` would carry over stale cached `model` and `contextTokens` values from the previous session into the newly created session entry. The `contextTokens` field was the primary culprit — `buildStatusMessage` in `src/auto-reply/status.ts` uses `entry?.contextTokens` with highest priority, so a stale value would cause the welcome message to display an incorrect context window size. The `model` cached field was also being carried over unnecessarily, though it had less direct impact on the welcome display.
- Removed `model: entry?.model` from the reset `nextEntry` construction so it defaults to `undefined`
- Changed `contextTokens: entry?.contextTokens` to `contextTokens: undefined` with a clear explanatory comment
- These cached fields are re-populated naturally on the next LLM run via `session-usage.ts`, so clearing them on reset is safe
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it's a minimal, well-scoped bug fix with no risk of regressions.
- The change is a two-line removal/modification in a single file. It stops carrying over cached display-only fields (`model`, `contextTokens`) that are re-populated on the next LLM run. The fix aligns with how other cached fields (like `modelProvider`) were already handled — they were never carried over in the reset path. No new logic is introduced, and the existing test suite (1073 tests) passes.
- No files require special attention.
<sub>Last reviewed commit: c04344f</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11613: fix: clear stale model metadata on /new and /reset
by mcaxtr · 2026-02-08
85.9%
#21847: fix(session): /new and /reset no longer carry over model overrides
by hydro13 · 2026-02-20
85.3%
#17011: fix(/new /reset): clear model override for reset turn
by Limitless2023 · 2026-02-15
85.3%
#21731: Fix: clear stale session runtime model on /new, /reset, and session...
by AIflow-Labs · 2026-02-20
85.0%
#21876: fix(session): clear model override on /new and /reset
by sauerdaniel · 2026-02-20
83.8%
#21849: fix(session): clear model/provider overrides on /new and /reset
by widingmarcus-cyber · 2026-02-20
83.6%
#16478: fix(gateway): fall back to lookupContextTokens on model switch
by colddonkey · 2026-02-14
81.4%
#20185: fix(model): recognize default/reset/clear keywords to clear session...
by yxshee · 2026-02-18
81.2%
#17414: fix(sessions): refresh contextTokens when model override changes
by michaelbship · 2026-02-15
80.7%
#16609: fix: resolve session store race condition and contextTokens updates
by battman21 · 2026-02-14
80.6%