Rolling Context is a local proxy that sits between Claude Code and the Anthropic API and compresses long conversations incrementally. When a session's context passes a trigger threshold (100K tokens by default), the proxy summarizes the older messages in the background and keeps roughly the most recent 40K tokens verbatim. The compressed prefix is injected on the next request, so no turn waits for compression. This differs from the built-in /compact command, which replaces the entire conversation with a single summary each time it runs.
Each compression cycle merges the new summary with the previous one into a single rolling record with sections for the active goal, previous goals, a numbered timeline, current state, and key details such as file paths and configuration decisions. Claude Code's own JSONL transcripts are left unchanged.
By default the summarization request clones the request Claude Code just sent (same model, system prompt, and tools, truncated at the cut point) with an added instruction to summarize, so the prefix is served from the prompt cache; a measured ~72K-token compression request cost about 400 fresh input tokens. Summarization can instead run on a separate Anthropic-format or OpenAI-compatible endpoint, including local models through Ollama, LM Studio, or vLLM. The proxy is stateless: it keys compressions by content hashes rather than sessions, so multiple conversations, subagents, and branches work without coordination. Written in Python with no dependencies beyond the standard library.
Features
- Threshold-based compression: triggers at a configurable token count and retains a configurable tail of recent messages verbatim
- Rolling summary merge: each cycle merges the previous summary with the newly compressed messages instead of summarizing a summary
- Background execution: compression runs asynchronously and applies on the following request
- Native summarization mode: reuses the session's own request shape and model so the summarization prefix is a prompt-cache read
- Alternative summarizer endpoints: any Anthropic-format or OpenAI-compatible API, including local models, can perform the summarization
- Non-Anthropic upstreams: chains to GLM/Z.ai, DeepSeek, OpenRouter, or another proxy, with a flattened-request fallback when an endpoint rejects cloned fields
- Per-session and global toggles: /rolling-context:on and :off commands apply from the next request, and subagents inherit their parent session's setting
- Stateless design: compressions are keyed by message content hashes, with no session tracking or database
- Health and debug endpoints: /health reports version and compression stats; /debug/compressions returns stored summaries
- Environment configuration: trigger, target, port, upstream, summarizer model, concurrency, and log rotation are all set through environment variables
