FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: clear tool output and attachments during compaction prune by guazi04 · Pull Request #16162 · anomalyco/opencode · GitHub

fix: clear tool output and attachments during compaction prune - #16162

Closed
guazi04 wants to merge 1 commit into
anomalyco:devfrom
guazi04:fix/prune-clear-output
Closed

fix: clear tool output and attachments during compaction prune#16162
guazi04 wants to merge 1 commit into
anomalyco:devfrom
guazi04:fix/prune-clear-output

Conversation

guazi04 commented Mar 5, 2026

Copy link
Copy Markdown

Problem

When compaction prunes old tool outputs, only the time.compacted timestamp was being set — the actual output string and attachments array remained in storage indefinitely. This caused unbounded storage growth.

Evidence:

  • Database size: 774 MB after 3 weeks of usage
  • Storage breakdown: 81% part data (unpruned outputs), 0.07% summaries
  • Duplicate tool invocations accumulating due to incomplete pruning

Solution

This PR clears the actual data when marking parts as compacted:

  1. compaction.ts (2 lines):

    • Clear output and attachments array in prune() when setting time.compacted
  2. prompt.ts (2 calls):

    • Add prune() calls before both compaction triggers to reduce context before LLM summarization
    • Reduces token count and storage footprint simultaneously
  3. Tests (new coverage):

    • Verify prune clears output/attachments when compaction.enabled=true
    • Verify prune respects compaction.enabled=false (skips clearing)
    • Test integration with both compaction trigger points

Testing

  • Unit tests: prune() behavior with/without config
  • Test fixtures cover clearing behavior verification
  • No breaking changes to existing API

Fixes part of #16101

When compaction prunes old tool outputs, only the `time.compacted` timestamp
was being set — the actual output string and attachments array remained in
storage indefinitely. This caused unbounded storage growth (observed 774 MB
database in 3 weeks, with 81% being part data).

Changes:
- Clear output and attachments when prune marks parts as compacted
- Add prune() calls before both compaction triggers in prompt.ts to reduce
  context before LLM summarization
- Add tests for prune clearing behavior and config respect

Fixes part of anomalyco#16101

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 5, 2026

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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.

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found related PRs that address similar issues:

Potentially Related PRs:

  1. PR fix: resolve memory leak issues across multiple subsystems #14650 - "fix: resolve memory leak issues across multiple subsystems"

  2. PR fix: clear tool output and attachments when pruning to prevent memory leak #7049 - "fix: clear tool output and attachments when pruning to prevent memory leak"

  3. PR feat(opencode): prune old tool outputs before compaction #14827 - "feat(opencode): prune old tool outputs before compaction"

Note: PR #7049 appears to be addressing the same core problem (clearing tool output and attachments to prevent memory/storage leaks). You should verify if this is a duplicate or if PR #16162 is an update/fix to the previous approach.

guazi04 commented Mar 5, 2026

Copy link
Copy Markdown
Author

Superseded by #16175 which includes this fix plus the full MVP (CLI commands, VACUUM support, cross-project cascade fix).

guazi04 closed this Mar 5, 2026
guazi04 deleted the fix/prune-clear-output branch March 5, 2026 13:10
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

Labels

needs:compliance This means the issue will auto-close after 2 hours. needs:issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL