{"slug": "agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its", "title": "Agent context compression tools: Headroom, RTK, Engram, Attic and how each one measured its saving", "summary": "As of 16 October 2026, seven open-source context compression tools sit between a coding agent and the model to cut what it reads, including two compressors (Headroom and RTK), two code indexes (Engram and cocoindex-code), two memory stores (Attic and memshare) and one prompt-cache fixer, with every headline saving measured by its own authors on their own workload. The article recommends RTK for a Claude Code or Codex user whose prompt cache already works, because its hook rewrites only shell output, reports what it changed and leaves the prompt cache alone. Claude Code's built-in compaction replaces message history with a summary and re-reads up to five recent files, while a model with a native 1M window compacts at about 967K tokens by default.", "body_md": "# Agent context compression tools: Headroom, RTK, Engram, Attic and how each one measured its saving\n\nAs of 16 October 2026, seven open-source tools sit between a coding agent and the model to cut what it reads: two compressors (Headroom and RTK), two code indexes (Engram and cocoindex-code), two memory stores (Attic and memshare) and one prompt-cache fixer. Every headline saving among them was measured by its own authors, on their own workload. For the common case, a [Claude Code](https://stackness.dev/tools/claude-code) or [Codex](https://stackness.dev/tools/codex-cli) user whose prompt cache already works, start with [RTK](https://stackness.dev/tools/rtk): its hook rewrites only shell output, reports what it changed and leaves the prompt cache alone.\n\n## What does a context compression tool do that built-in compaction does not?\n\nA context compression tool acts on single payloads before the model reads them, while built-in compaction rewrites the whole conversation once the window is nearly full. Claude Code's compaction \"replaces your message history with a summary\", which invalidates the cached conversation but not the cached system prompt ([caching docs](https://code.claude.com/docs/en/prompt-caching)), and then re-reads up to five recent files ([docs](https://code.claude.com/docs/en/context-window)). A model with a native 1M window compacts at about 967K tokens by default.\n\nAnthropic's [cookbook](https://platform.claude.com/cookbook/tool-use-context-engineering-context-engineering-tools) names the three moves this layer is built from: \"compaction compresses the whole window when it grows too large, clearing drops stale re-fetchable data inside the window, and memory moves information out of the window so it survives across sessions.\" Compressors apply clearing to each payload on the way in, memory stores move findings to disk, and indexes add a fourth move: not reading the payload at all.\n\nThe [compaction explainer](https://stackness.dev/blog/what-is-context-compaction-in-coding-agents-and-what-does-it-quietly-lose) covers what the built-in summary loses, and the [memory versus documentation post](https://stackness.dev/blog/agent-memory-vs-documentation-which-slot-a-memory-plugin-fills-and-which-one-the-repo-does) covers when a memory store is the wrong slot.\n\n## How the seven were picked and what was left out\n\nThe seven tools here are installable today, run beside an existing coding agent rather than replacing it, and publish either a saving or a clear statement that they do not. Stars, licences and releases come from the GitHub API and package registries on 16 October 2026. Fact lines follow one order: kind, where it sits, licence, agents, latest release, stars.\n\nLeft out, and why:\n\n- **SOKKAN** , a self-hosted cockpit that injects project memory into parallel Claude Code sessions, with non-Claude session engines still on its roadmap and a paid managed version from 129 CHF a month ([repo](https://github.com/ninabot-ch/sokkan) ).\n- **context-compress** , which rewrites instruction files: the PyPI name in its README belongs to a different author's package ([PyPI](https://pypi.org/project/context-compress/) ). Its own test appears in the failures section.\n- **[mem0](https://stackness.dev/tools/mem0)** ,**[Serena](https://stackness.dev/tools/serena)** and**[Context7](https://stackness.dev/tools/context7)** , which feed or organize context rather than sit between the agent and the model to compress it.\n- Compaction built into LangChain Deep Agents, Agno and Hermes Agent, which does not sit beside another agent.\n\nNone of the seven appears on a public Stackness stack as of 16 October 2026; RTK is in the catalog with no members yet ([data sources](https://stackness.dev/about/data-sources)).\n\n## Seven tools that sit between a coding agent and the model\n\nThe seven tools below differ most in what they touch: RTK and Headroom change tool output, Engram and cocoindex-code change what the agent reads, Attic and memshare change what the next session starts with, and prompt-cache-skills changes the harness itself.\n\n### Headroom\n\nCompressor · library, local proxy, agent wrapper and MCP server · Apache-2.0 · 18 named agents plus any OpenAI-compatible client · v0.41.0, 14 October 2026 · 75,468 stars.\n\n[Headroom](https://stackness.dev/tools/headroom) compresses logs, JSON and other tool output before it reaches the provider and keeps the originals locally for the model to fetch back; `headroom wrap claude` sets it up ([README](https://github.com/headroomlabs-ai/headroom)). Its headline, 55,957 tokens down to 24,340, is one seeded run on a synthetic incident-debugging payload: 300 generated log entries, 200 database rows and 150 file results. The script counts tool-result tokens only, and with `protect_recent=0`, a setting that is not the default. The same script's docstring says the docs' earlier figures \"could not be reproduced by anyone, including us\". Source code passes through unchanged ([limitations](https://docs.headroomlabs.ai/docs/limitations)).\n\nTwo defaults to know: an anonymous telemetry beacon is on unless you set `HEADROOM_BEACON=off`, and `headroom wrap` also installs Serena, which is GPL-3.0-or-later, unless you pass `--code-memory none`.\n\n**Pick it** when your sessions are dominated by large, repetitive tool output and you use more than one agent. Its README says to skip it if you \"only use one provider's native compaction and don't need cross-agent memory\".\n\n### RTK\n\nCompressor · shell command hook · Apache-2.0 plus BUSL-1.1 for the full build, Apache-2.0 only for `rtk-oss` · 18 AI coding tools · v1.0.1, 14 October 2026 · 83,556 stars.\n\nRTK rewrites shell commands the agent runs into `rtk` equivalents and returns trimmed output: failures only from `cargo test` or `pytest`, hash, author and subject from `git log`. `rtk init -g` installs a PreToolUse hook in Claude Code; `--codex` and `--agent cursor` cover the others ([README](https://github.com/rtk-ai/rtk)). It claims up to 90% less bash output, measured as bytes of raw against filtered output divided by four, since it ships no tokenizer. The project says plainly that this \"is not the same as cutting your bill by the same amount\" ([README](https://github.com/rtk-ai/rtk#how-savings-work)). The hook fires only on Bash calls, so Claude Code's built-in Read, Grep and Glob tools pass through untouched.\n\n**Pick it** when the agent runs a lot of tests, builds and git commands. `rtk gain` shows what it saved per command.\n\n### Engram\n\nCode index and project memory · CLI, agent hooks, MCP server and an OpenVSX extension · Apache-2.0 · 8 IDEs ([Cursor](https://stackness.dev/tools/cursor), [Cline](https://stackness.dev/tools/cline), Claude Code, Codex and four more) · v4.5.0, 21 June 2026 · 143 stars.\n\n[Engram](https://stackness.dev/tools/engram) builds a local structural graph of the repository and intercepts file reads to hand the agent a packet instead of the whole file. Its 89% figure, still in the repo description, came from Engram's own repository on 24 April 2026: 87 files, 163,122 tokens read raw against 17,722 in packets ([report](https://github.com/NickCirv/engram/blob/9fa2a4b74ca8e66560d74d1255c16c43157d32bd/bench/results/real-world-2026-04-24.md)). The earlier README said the number \"is **not** an agent-loop cost-savings figure\", and added: \"engram's net over prompt caching ≈ 0\". The current README dropped the number.\n\n**Pick it** when the agent wastes turns reading whole files across several IDEs and you accept that the saving is in packet size, not the bill. Its last release was four months ago.\n\n### cocoindex-code\n\nCode index · CLI (`ccc`), agent skill and MCP server · Apache-2.0 · any agent with skills or MCP · v0.2.42, 5 October 2026 · 2,909 stars.\n\n[cocoindex-code](https://stackness.dev/tools/cocoindex-code) is AST-based semantic code search built on [CocoIndex](https://stackness.dev/tools/cocoindex), an incremental indexing framework with 11,710 stars that re-embeds only changed files. `claude mcp add cocoindex-code -- ccc mcp` adds it to Claude Code, and the full build embeds locally ([README](https://github.com/cocoindex-io/cocoindex-code)). Its README promises \"token saving by 70%\". I found no workload, baseline or sample behind that number in the repository or on the product page.\n\n**Pick it** for a large repository where you want local semantic search exposed as a tool, with no number to plan around.\n\n### Attic\n\nMemory store · plugin with skills and hooks · MIT · Claude Code and Codex CLI · v1.6.1, 23 September 2026 · 5 stars.\n\n[Attic](https://stackness.dev/tools/attic) writes what an investigation found to `.attic/` as plain Markdown, with the files and commit each finding rests on, and injects a short index each session and after `/compact`. On recall it flags a finding as possibly stale when those files changed ([README](https://github.com/NishikantaRay/Attic)).\n\n*Image: [How Attic works](https://github.com/NishikantaRay/Attic) by Nishikanta Ray, [MIT](https://github.com/NishikantaRay/Attic/blob/main/LICENSE).*\n\nAttic publishes the most detail about its measurement: three headless Claude Code sessions on one private monorepo on 6 September 2026, input tokens down from 5,935,224 to 3,938,927 (34%) and cost from $6.35 to $5.02, with both arms passing 13 of 13 checks. The author's words: \"One run of each arm, one repository, one model. No confidence interval.\" On a short session the index cost 2.5% more.\n\n**Pick it** for long investigations that span `/compact` and new sessions, when you want findings a team can commit and review.\n\n### memshare\n\nShared memory · MCP server and CLI · MIT · any MCP client · npm `memshare-mcp` 0.7.5, 21 September 2026 · 0 stars.\n\n[memshare](https://stackness.dev/tools/memshare) keeps a local memory store and lets you export a reviewed subset as a bundle that a teammate imports item by item, with a scan for personal data first ([README](https://github.com/kampana/memshare)). Install it as `memshare-mcp`; the plain `memshare` name on npm is a different package. It claims no token saving, and its README states the limit of every MCP memory: \"nothing in MCP can force a model to call a tool, so capture can quietly not happen and you would not find out for weeks.\"\n\n**Pick it** to hand what one assistant learned to a colleague on a different agent.\n\n### prompt-cache-skills\n\nCache fixer · 13 skill files that patch harness source · CC BY 4.0 for prose, MIT for code · patches Cline, Roo Code, Continue, OpenCode and Aider · no releases, last change 29 August 2026 · 115 stars.\n\n[prompt-cache-skills](https://stackness.dev/tools/prompt-cache-skills) is a set of instructions an agent follows to find and fix the places where an open-source harness breaks provider prompt caching, with a script that sends a request twice and diffs the cache fields ([README](https://github.com/OnlyTerp/prompt-cache-skills)). Its \"10x\" badge is list-price arithmetic, not a measurement, and its own 28 August re-check says an earlier \"copy-paste bug\" framing \"was wrong\". By its own audit, Claude Code and Codex CLI need nothing from it.\n\n**Pick it** if you run Cline, Roo Code, Continue, OpenCode or Aider from source and suspect caching is off.\n\n## Every headline saving was measured by its own authors\n\nEach tool's headline percentage measures something different, and none of them has been reproduced by anyone outside the project in any source I found. Headroom counts tool-result tokens on synthetic data, RTK counts shell bytes, Engram compares packets with whole files, and Attic compares one run of three real sessions with the plugin on against one with it off.\n\n| Tool | Headline | What was measured | Sample | Rerun it yourself | \n|---|---|---|---|---|\n| Headroom | 57% (55,957 to 24,340) | Tool-result tokens, synthetic payload, non-default setting | 1 seeded run | Yes, offline script | \n| RTK | Up to 90% | Shell output bytes, raw against filtered | Your own `rtk gain` | Yes, on every command | \n| Engram | 89.1% | Packet against whole file, Engram's own repo | 87 files, 1 run | Yes, on any repo | \n| cocoindex-code | 70% | Not stated | Not stated | No | \n| Attic | 34% input, 21% cost | Real Claude Code sessions, plugin on against off | 1 run per arm | Harness yes, repo private | \n| memshare | None claimed | n/a | n/a | n/a | \n| prompt-cache-skills | 10x | List-price arithmetic for a cached prefix | None | Cache check script | \n\nThe only outside data point is indirect: in [The Complexity Trap](https://arxiv.org/abs/2508.21433), plain observation masking halved SWE-agent's cost on SWE-bench Verified while matching the solve rate of LLM summarization.\n\n## A compressor that drops the wrong line fails without an error\n\nA compressor that removes the wrong line produces output that still looks valid, so the agent acts on it instead of retrying. The documented cases are in Headroom's issue tracker and in context-compress's own test, and the pattern matches what an EMNLP 2026 paper calls decontextualization: evidence kept but cut off from the caveat that qualified it ([arXiv 2606.29251](https://arxiv.org/abs/2606.29251)).\n\n- **Output that looks like data.** In Headroom[issue #3590](https://github.com/headroomlabs-ai/headroom/issues/3590) ,`ls -la` came back as a row of bare numbers. The reporter put the difference this way: \"Truncation announces itself and you retry.\" The numbers did not, and the agent read them as data. Excluding Bash, Read, Grep and Glob fixed it, with session savings around 20%.\n- **Line numbers glued to the wrong content.**[Issue #3545](https://github.com/headroomlabs-ai/headroom/issues/3545) , closed on 30 September after a related fix, showed grep matches fused onto one line's text, which \"manufactures false line↔︎content associations\".\n- **A safety rule that stopped holding.** Alexey Vidanov[compressed](https://dev.to/aws-builders/i-ab-tested-compressed-agent-instructions-and-found-the-breaking-point-3h7k) an instruction file by 55% and the agent stopped asking permission before creating files. Merging eight safety bullets into three sentences made it ask once in three runs.\n- **A cheaper call that cost more.** One Headroom user[reported](https://github.com/headroomlabs-ai/headroom/issues/1636) hitting usage limits faster after installing it, because rewritten prompts missed the cache. A second user confirmed it with usage data, and a cache fix ([PR #2917](https://github.com/headroomlabs-ai/headroom/pull/2917) ) shipped on 11 August 2026.\n\n## Headroom, RTK, Engram and the rest side by side\n\nThe columns that decide for most readers are where each tool sits and how many agents it works with. Four of the seven work with any MCP client and RTK with 18 named agents; Attic covers Claude Code and Codex CLI, and prompt-cache-skills five open-source harnesses.\n\n| Tool | Kind | Where it sits | Agents | Licence | Install | \n|---|---|---|---|---|---|\n| Headroom | Compressor | Proxy, wrapper, library, MCP | 18 named, any OpenAI-compatible | Apache-2.0 | `uv tool install --python 3.13 \"headroom-ai[all]\"` | \n| RTK | Compressor | Shell hook | 18 | Apache-2.0 (+ BUSL-1.1) | `brew install rtk` | \n| Engram | Index, memory | Hooks, MCP, IDE extension | 8 IDEs | Apache-2.0 | source build | \n| cocoindex-code | Index | CLI, skill, MCP | Skill or MCP clients | Apache-2.0 | `pipx install 'cocoindex-code[full]'` | \n| Attic | Memory | Plugin | Claude Code, Codex CLI | MIT | `claude plugin marketplace add NishikantaRay/Attic` , then`claude plugin install attic@attic` | \n| memshare | Shared memory | MCP, CLI | Any MCP client | MIT | `npm install -g memshare-mcp` | \n| prompt-cache-skills | Cache fixer | Skills that patch harness code | 5 open-source harnesses | CC BY 4.0, MIT | `git clone` into skills | \n\nMore tools in this layer turn up among the [AI tools developers list](https://stackness.dev/categories/ai-tools) and the [terminal and shell tools](https://stackness.dev/categories/terminal-shell) RTK sits beside.\n\n## Which one for which agent, team and budget\n\n- **Claude Code or Codex, cache working, shell-heavy sessions:** RTK, the`rtk-oss` build if you want Apache-2.0 only.\n- **Several agents and huge JSON or log output:** Headroom, with the beacon off,`--code-memory none` , and Bash, Read, Grep and Glob excluded until you trust it.\n- **Large repository, agent reading whole files:** cocoindex-code for local semantic search; Engram if you also want its hooks across eight IDEs.\n- **Long investigations that outlive `/compact`:** Attic.\n- **Sharing what an assistant learned with a teammate:** memshare.\n- **Cline, Roo Code, Continue, OpenCode or Aider from source:** prompt-cache-skills first, since a broken cache costs more than anything a compressor saves.\n- **Short sessions:** none of them. Attic measured its own index as overhead there, and[/clear](https://stackness.dev/blog/when-more-context-makes-your-coding-agent-worse-subagent-compact-clear-or-a-headless-loop) costs nothing.\n\n## New posts by email\n\nAbout one email a week with what we published. No account needed.\n\n## Which of these do you use?\n\nNobody on Stackness runs RTK yet. Tick what you use and be the first.\n\n[Play Lonny Eagle Amateur Skater 4A pixel art skateboarding game. Signing up opens it straight away.Sign up to play](https://stackness.dev/games/lonny-eagle)", "url": "https://wpnews.pro/news/agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its", "canonical_source": "https://stackness.dev/blog/agent-context-compression-tools-headroom-rtk-engram-attic-compared", "published_at": "2026-10-16 09:00:45+00:00", "updated_at": "2026-10-16 09:41:00.379483+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models", "ai-products"], "entities": ["Headroom", "RTK", "Engram", "Attic", "cocoindex-code", "memshare", "Claude Code", "Codex"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its", "markdown": "https://wpnews.pro/news/agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its.md", "text": "https://wpnews.pro/news/agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its.txt", "jsonld": "https://wpnews.pro/news/agent-context-compression-tools-headroom-rtk-engram-attic-and-how-each-one-its.jsonld"}}