Rolling Context sits between Claude Code and the Anthropic API as a transparent local proxy that manages the context window automatically. Rather than compacting the whole conversation at once, it keeps recent messages verbatim and summarizes only older ones once the context passes a token threshold (100K by default), so a long session can continue without hitting the context limit. It uses the existing Claude Code authentication and requires no API key, and runs on pure Python standard library.
The tool contrasts itself with Claude Code's built-in /compact, which replaces the entire conversation with a lossy summary and, over repeated runs, ends up summarizing a summary. Here, each compression cycle merges the previous summary with newly aged-out messages into a rolling timeline while the newest ~40K tokens stay untouched, and summarization runs in the background so it does not block requests. The original JSONL transcripts are left unmodified.
The proxy is stateless: it hashes message content, stores the compressed result keyed by those hashes, and swaps in the compressed version when a matching request arrives. This lets multiple conversations, subagents, and branches work without session tracking, and the proxy can be restarted at any time. It can also chain in front of another proxy (model router or API gateway) by treating an existing base URL as its upstream.
Behavior is tuned through optional environment variables, including the trigger token count, the number of recent tokens kept verbatim, the summarization model, the listen port, and upstream/custom-summarizer endpoints. The generated summary is structured into sections such as active goal, previous goals, a numbered timeline of changes and decisions, current state, and key details, and health and debug endpoints expose compression stats and stored summaries.
