GeezerVison is showing github.com — fix(session): clear compacted tool output by honeyspoon · Pull Request #16785 · anomalyco/opencode
Conversation
honeyspoon
commented
Mar 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #16786
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
When a completed tool part is marked compacted, this also clears part.state.output.
OpenCode already treats compacted tool results as cleared when rebuilding model messages, so keeping the stored output string around is unnecessary in long sessions with large tool outputs.
This keeps the write path aligned with the existing read path with a one-line behavioral change in packages/opencode/src/session/compaction.ts.
How did you verify your code works?
I tested this locally with repeated long single-session benchmarks.
Representative medians over 20 iterations:
tools-single-session
- candidate: delta RSS
54.54 MB, peak RSS 602.42 MB
- baseline: delta RSS
62.7 MB, peak RSS 619.78 MB
bash-single-session
- candidate: delta RSS
5.72 MB, peak RSS 661.2 MB
- baseline: delta RSS
11.28 MB, peak RSS 683.63 MB
lsp-single-session
- candidate: delta RSS
5.13 MB, peak RSS 690.45 MB
- baseline: delta RSS
5.36 MB, peak RSS 714.41 MB
I also ran the repository typecheck via the push hook when pushing the branch.
Screenshots / recordings
N/A
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR doesn't fully meet our contributing guidelines and PR template.
What needs to be fixed:
- PR description is missing required template sections. Please use the PR template.
Please edit this PR description to address the above within 2 hours, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number> or Closes #<number> to this PR description
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
Based on my search, I found several related PRs addressing memory and session issues. The most relevant are:
Potentially Related PRs:
-
#7049 - "fix: clear tool output and attachments when pruning to prevent memory leak"
- Directly related: also clears tool output for memory optimization, but focuses on pruning instead of compaction
-
#10392 - "fix(opencode): memory leaks in session handling"
- Related: addresses memory leaks in session handling broadly
-
#16346 - "fix(opencode): unbounded memory growth during active usage"
- Related: recent PR addressing similar unbounded memory growth concerns
-
#16730 - "fix(opencode): reduce memory usage and database bloat in long-running instances"
- Related: recent PR for memory usage reduction in long-running sessions
These PRs address related memory retention issues, though none appear to be exact duplicates of PR #16785's specific approach of clearing output during compaction.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Closing and recreating this PR now that the linked issue and template-compliant description are in place, to clear the stale compliance labels.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|