anomalyco / anomalyco/opencode
Compaction clones large tool output without transform hooks
@nexxeln is already working on this.
Since Aug 31, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Compaction always runs structuredClone(selected.head) before serializing history, even when no experimental.chat.messages.transform hook exists. Completed tool output is reduced to 2,000 characters only after that clone.
In five fresh Bun 1.3.14 processes, an isolated 64 MiB synthetic tool result reached 293.6 MB median max RSS with the clone versus 159.2 MB when serialized directly. This measures the copy mechanism, not whole-application RSS.
The no-hook path should serialize directly. The existing clone must remain when a transform hook is registered so plugin mutations cannot alter source history.
Plugins
None
OpenCode version
dev at 10765ff2a9da8c3b88e4de873aa383a49c318912
Steps to reproduce
- Create a completed tool part with a 64 MiB output string.
- Compare bounded serialization directly against
structuredClonefollowed by the same serialization. - Observe the extra copy only in the clone path.
Screenshot and/or share link
No response
Operating System
macOS 26.5.2 arm64
Terminal
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.