anomalyco / anomalyco/opencode
[FEATURE]: Context token deduplication to prevent 8M+ token long sessions
Open
@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
- Tool Output Deduplication: Replace prior file read results in the context with a reference pointer when the file is read a second time.
- Subagent Output Pruning: Truncate raw subagent execution steps from the primary agent session context before returning the final subagent response.
- 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
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.