Compacted tool outputs and attachments not cleared from storage, causing memory growth #4485

Closed
opened 2026-02-16 17:44:20 -05:00 by yindo · 2 comments
Owner

Originally created by @hendem on GitHub (Jan 8, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

When compaction prunes old tool outputs (in packages/opencode/src/session/compaction.ts), only the time.compacted timestamp is being set. The actual output string (often containing large file contents) and attachments array (base64 images/PDFs from the Read tool) remain in the storage JSON files indefinitely.

This causes storage files to grow unbounded, contributing to memory issues during extended use.

Expected Behavior

When prune() marks tool parts as compacted, it should also clear the output string and attachments array to free memory.

Actual Behavior

Only time.compacted is set; large output strings and attachment data persist indefinitely.

Related

Originally created by @hendem on GitHub (Jan 8, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem When compaction prunes old tool outputs (in `packages/opencode/src/session/compaction.ts`), only the `time.compacted` timestamp is being set. The actual `output` string (often containing large file contents) and `attachments` array (base64 images/PDFs from the Read tool) remain in the storage JSON files indefinitely. This causes storage files to grow unbounded, contributing to memory issues during extended use. ## Expected Behavior When `prune()` marks tool parts as compacted, it should also clear the `output` string and `attachments` array to free memory. ## Actual Behavior Only `time.compacted` is set; large output strings and attachment data persist indefinitely. ## Related - Part of the memory leak issues reported in #4315, #5363
yindo added the perf label 2026-02-16 17:44:20 -05:00
yindo closed this issue 2026-02-16 17:44:20 -05:00
Author
Owner

@hendem commented on GitHub (Jan 8, 2026):

Closing - will use existing issue #4315

@hendem commented on GitHub (Jan 8, 2026): Closing - will use existing issue #4315
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7420: Memory leak: compacted tool outputs and attachments not cleared from storage
  • #4315: Memory stays unbounded: ACP session map + compacted tool outputs
  • #5363: opencode eating 70gb of memory?

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue might be a duplicate of existing issues. Please check: - #7420: Memory leak: compacted tool outputs and attachments not cleared from storage - #4315: Memory stays unbounded: ACP session map + compacted tool outputs - #5363: opencode eating 70gb of memory? Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4485