← Back to PRs

#14018: fix: auto-remind AI to check workspace context files on session reset

by WalterSumbon open 2026-02-11 09:58 View on GitHub →
stale
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