-
Couldn't load subscription status.
- Fork 3.7k
fix: CLI context pollution between sessions #8420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Resolves context pollution issue where CLI sessions would retain state from previous invocations, causing responses to reference conversations that should have been isolated. Changes: - Added SessionManager.reset() static method for proper cleanup - Updated initializeChatHistory() to create new session by default - Clear undo/redo stacks in ChatHistoryService on initialization - Added comprehensive session isolation tests Fixes CON-4530 Co-authored-by: Username <nate@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
The vi.mock setup already properly types the uuid v4 function to return string, so the 'as any' type assertions are unnecessary and were creating TypeScript smell in the test file. This change improves type safety while maintaining the same test behavior. Co-authored-by: Username <nate@continue.dev> Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 5 files
Generated with [Continue](https://continue.dev) Co-Authored-By: Continue <noreply@continue.dev>
Summary
Fixes context pollution issue in the Continue CLI where sessions would retain state from previous invocations, causing the LLM to reference conversations from prior sessions even when starting fresh (without --resume).
Problem
As reported in #7916 and described in CON-4530, the CLI was maintaining state in singleton services across separate CLI invocations. This meant:
cn "Tell me about dogs", having a conversation, then exitingcn "What were we discussing?"in a new sessionRoot Cause
Three main sources of state pollution:
currentSessionacross invocationsSolution
1. Session Management (session.ts)
SessionManager.reset()static method for proper cleanup2. Chat Initialization (chat.ts)
initializeChatHistory()to explicitly create a new session when neither--resumenor--forkflags are used3. Service Cleanup (ChatHistoryService.ts)
4. Tests (session.test.ts)
Testing
The fix includes three new test cases:
should not pollute new sessions with previous session historyshould create independent sessions for concurrent operationsshould properly clear session state when transitioning between sessionsBehavior Changes
Before
After
Flags Still Work as Expected
cn --resume: Continues most recent session ✅cn --fork <id>: Forks from specific session ✅cn(no flags): Clean new session ✅Related Issues
Fixes CON-4530
Closes #7916
This agent session was co-authored by Brian Douglas and Continue.
Summary by cubic
Fixes CLI context pollution so new sessions start clean and don't inherit history from previous runs. Applies to fresh invocations; sessions only carry over when using --resume or --fork. Addresses Linear CON-4530.