← Back to PRs

#11613: fix: clear stale model metadata on /new and /reset

by mcaxtr open 2026-02-08 02:16 View on GitHub →
agents size: M trusted-contributor experienced-contributor
## Summary - Clears `model`, `modelProvider`, and `systemPromptReport` fields when session is reset via `/new` or `/reset` - These fields reflect the LAST turn's state and shouldn't persist after reset - Follows the same pattern as #8929 which cleared token metrics on reset Fixes #10404 Fixes #10834 ## Test plan - [x] Write failing test that reproduces stale model metadata bug - [x] Implement fix in `session.ts` to clear fields on `isNewSession` - [x] Verify all 6 new tests pass - [x] Full CI gate: `pnpm build && pnpm check && pnpm test` (5611 tests pass) - [x] Codex review loop completed ## Testing performed 1. Created session with model metadata from previous turn 2. Triggered `/new` command 3. Verified `model`, `modelProvider`, `systemPromptReport` are cleared 4. Verified token metrics are also cleared (existing behavior) 5. Verified sticky overrides (`modelOverride`, `providerOverride`) are preserved ## Changes - `src/auto-reply/reply/session.ts`: Clear stale model fields in `isNewSession` block - `src/auto-reply/reply/session-model-reset.test.ts`: New test file with 2 tests <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates session initialization so that when a reset is triggered via `/new` or `/reset`, the session entry also clears turn-specific model metadata (`model`, `modelProvider`, `systemPromptReport`) alongside the already-cleared token metrics. It also adds regression tests that construct a session store with persisted model fields, trigger `initSessionState()` via a reset command, and assert that the resulting persisted entry no longer contains the stale fields. The change is localized to `src/auto-reply/reply/session.ts`’s `isNewSession` handling, which is where other “reset should wipe last-turn state” fields are already cleared. Two new Vitest suites cover both session reset behavior and the system-prompt runtime model line behavior. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Changes are small, scoped to the session reset path, and add targeted regression tests. The previous review concerns called out in the PR (session store cache and import paths) are already addressed/validated by the updated code and existing resolution notes. No additional correctness or safety issues were found in the modified logic. - No files require special attention <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs