fix(session): add message limit warning to prevent memory leaks in long-running sessions#1341
Open
walker83 wants to merge 1 commit into
Open
fix(session): add message limit warning to prevent memory leaks in long-running sessions#1341walker83 wants to merge 1 commit into
walker83 wants to merge 1 commit into
Conversation
…ng-running sessions Add MAX_MESSAGES_PER_SESSION constant (1000) and warning log when sessions exceed this limit. This helps users identify when to start a new session or run /compact to avoid the memory issues reported in XiaomiMiMo#1221. Related: XiaomiMiMo#1221, XiaomiMiMo#813, XiaomiMiMo#680 Refs: XiaomiMiMo#1221
e238733 to
7f06d5a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add session message limit warning to prevent memory leaks
Summary
This PR adds a warning log when session message count exceeds 1000 messages, helping users identify potential memory leak issues in long-running sessions.
Problem
As reported in #1221, long-running sessions (>200k tokens) become extremely slow and eventually crash. Root cause analysis shows that:
Solution
Add
MAX_MESSAGES_PER_SESSION = 1000constant and log a warning when exceeded:Changes
packages/opencode/src/session/compaction.ts:MAX_MESSAGES_PER_SESSIONexport constantprocessCompactionfunctionTesting
session.message-limit-exceededRelated Issues
Checklist
Notes
This is a diagnostic fix that adds visibility into the memory issue. Future PRs could: