anomalyco / anomalyco/opencode

[FEATURE]: Context token deduplication to prevent 8M+ token long sessions

Open
#38,927 1 comment 1 reaction 1 assignee View on GitHub

@jlongster is already working on this.

Since Jul 26, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Verification
  • I searched for existing feature requests.
Description

Analysis of real-world session telemetry from 21 sessions across TodoUI and system configs reveals that OpenCode accumulates unreasonably large input token counts when running long coding sessions. One session exceeded 8 million input tokens, and another reached 3.7 million tokens. Redundant file reads accumulate in the context window and are passed to the model multiple times.

Proposed Solution
  1. Tool Output Deduplication: Replace prior file read results in the context with a reference pointer when the file is read a second time.
  2. Subagent Output Pruning: Truncate raw subagent execution steps from the primary agent session context before returning the final subagent response.
  3. Proactive Sliding-Window Compaction: Summarize older conversation turns continuously rather than running a heavy compaction pass only when context limits are reached.

This improvement alone could cut input token counts by an estimated 50–70% in long development sessions.

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.