[FEATURE] Context window deduplication for repeated token sequences

Resolved 💬 3 comments Opened Mar 29, 2026 by cmanfre4 Closed May 16, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Long Claude Code sessions accumulate significant token duplication in the context window. The same content appears multiple times through normal usage:

  • File contents re-read after edits (the full file appears in context each time)
  • Tool schemas repeated on every tool call
  • System prompts and skill text injected repeatedly via <system-reminder> tags
  • Git diffs that overlap heavily with previously read file contents

In a session that hits compaction, a substantial percentage of the context window is identical token sequences that have already appeared earlier in the conversation. This wastes context capacity that could hold useful working memory.

Proposed Solution

Deduplicate repeated token sequences within the context window. When a sequence of tokens is identical to one already present in context, reference it by pointer rather than repeating the tokens. This is analogous to how block-level deduplication works in storage systems.

This could operate at different levels:

  • Message level: detect when a tool result is identical to a previous one and reference it
  • Block level: detect large repeated subsequences across messages
  • Token level: general-purpose dedup of repeated runs above some minimum length

Even message-level dedup (the simplest) would recover significant space, since re-reading files is the most common source of duplication.

Scope

This is likely a model/infrastructure optimization rather than a Claude Code feature, but Claude Code is where users feel the impact most acutely. Filing here since this is the feedback channel.

Impact

Would meaningfully extend how long sessions can run before hitting compaction, and would increase effective context capacity without increasing the actual window size.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗