anomalyco / anomalyco/opencode

Compaction clones large tool output without transform hooks

Open
#46,331 0 comments 0 reactions 1 assignee View on GitHub

@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
  1. Create a completed tool part with a 64 MiB output string.
  2. Compare bounded serialization directly against structuredClone followed by the same serialization.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.