#14018: fix: auto-remind AI to check workspace context files on session reset
stale
Cluster:
Session Management Improvements
Fixes #13987
**Problem:**
When users reset a session with `/new` or `/reset`, the AI doesn't always actively check workspace context files (SOUL.md, USER.md, MEMORY.md, memory/*.md) even though they're loaded in the system prompt's "Project Context" section.
**Solution:**
When a session reset is triggered (`isNewSession && resetTriggered`), prepend an explicit system reminder to the body text:
```
[System: New session started. Review the Project Context section in your system prompt
(SOUL.md, USER.md, MEMORY.md, and recent memory/*.md files) before responding.]
```
**Behavior:**
- `/new` alone → reminder + "Greet the user based on the context above."
- `/new <text>` → reminder + user's text
- `/reset` → reminder + (existing text behavior)
- Regular messages → no reminder
**Testing:**
- Added 5 comprehensive test cases in `session.new-session-workspace-context.test.ts`
- Tests cover: bare /new, /new with text, /reset, regular messages, unauthorized resets
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds an explicit system reminder when users reset their session using `/new` or `/reset` commands. The reminder instructs the AI to review workspace context files (`SOUL.md`, `USER.md`, `MEMORY.md`, and `memory/*.md` files) that are already loaded in the system prompt's "Project Context" section.
**Key changes:**
- Added conditional logic to prepend a context reminder message when `isNewSession && resetTriggered` is true
- Updated `updateSessionStore` call to include session maintenance warning options (adding `activeSessionKey` and `onWarn` callback)
- Refactored body resolution into an `effectiveBody` variable to avoid duplication
- Added comprehensive test coverage with 5 test cases covering different reset scenarios
The implementation is clean and follows existing patterns in the codebase. The tests validate the behavior for bare `/new`, `/new` with text, `/reset`, regular messages, and unauthorized resets.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-tested, narrowly scoped, and follow established patterns in the codebase. The logic is straightforward (adding a reminder text when specific conditions are met), and the comprehensive test suite validates all important scenarios. The refactoring of the `updateSessionStore` call aligns with recent changes to session maintenance infrastructure.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11613: fix: clear stale model metadata on /new and /reset
by mcaxtr · 2026-02-08
81.9%
#6653: fix: persist archived session entry on /new or /reset
by leicao-me · 2026-02-01
80.8%
#14358: fix: preserve session overrides (verbose, model) across /new or /rese…
by WyattSanders · 2026-02-12
79.3%
#17375: fix(session): don't carry stale model info into reset welcome message
by BinHPdev · 2026-02-15
78.7%
#21847: fix(session): /new and /reset no longer carry over model overrides
by hydro13 · 2026-02-20
77.1%
#21876: fix(session): clear model override on /new and /reset
by sauerdaniel · 2026-02-20
76.8%
#22465: fix: preserve session history after API error (400/503) in mid-conv...
by hhy5562877 · 2026-02-21
76.4%
#18103: fix: session-memory hook reads reset file after /new or /reset
by MisterGuy420 · 2026-02-16
76.4%
#17109: fix: preserve responseUsage across session resets
by Limitless2023 · 2026-02-15
75.7%
#7537: fix(sessions): reset token counts on /new for channel sessions
by SoniAssist · 2026-02-02
75.3%