Stackness
Sign up
Agent context compression tools: Headroom, RTK, Engram, Attic and how each one measured its saving

Agent context compression tools: Headroom, RTK, Engram, Attic and how each one measured its saving

As 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 or Codex user whose prompt cache already works, start with RTK: its hook rewrites only shell output, reports what it changed and leaves the prompt cache alone.

What does a context compression tool do that built-in compaction does not?

A 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), and then re-reads up to five recent files (docs). A model with a native 1M window compacts at about 967K tokens by default.

Anthropic's cookbook 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.

The compaction explainer covers what the built-in summary loses, and the memory versus documentation post covers when a memory store is the wrong slot.

How the seven were picked and what was left out

The 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.

Left out, and why:

  • 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).
  • context-compress, which rewrites instruction files: the PyPI name in its README belongs to a different author's package (PyPI). Its own test appears in the failures section.
  • mem0, Serena and Context7, which feed or organize context rather than sit between the agent and the model to compress it.
  • Compaction built into LangChain Deep Agents, Agno and Hermes Agent, which does not sit beside another agent.

None 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).

Seven tools that sit between a coding agent and the model

The 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.

Headroom

Compressor · 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.

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). 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).

Two 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.

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".

RTK

Compressor · 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.

RTK 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). 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). The hook fires only on Bash calls, so Claude Code's built-in Read, Grep and Glob tools pass through untouched.

Pick it when the agent runs a lot of tests, builds and git commands. rtk gain shows what it saved per command.

Engram

Code index and project memory · CLI, agent hooks, MCP server and an OpenVSX extension · Apache-2.0 · 8 IDEs (Cursor, Cline, Claude Code, Codex and four more) · v4.5.0, 21 June 2026 · 143 stars.

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). 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.

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.

cocoindex-code

Code 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.

cocoindex-code is AST-based semantic code search built on 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). 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.

Pick it for a large repository where you want local semantic search exposed as a tool, with no number to plan around.

Attic

Memory store · plugin with skills and hooks · MIT · Claude Code and Codex CLI · v1.6.1, 23 September 2026 · 5 stars.

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).

Attic's how-it-works diagram. You work, reading five files and tracing a bug. Attic stashes the finding into a .attic folder holding items, an INDEX.md and a DECISIONS.md. The index is injected into the next session, after /compact too, which then answers without re-reading the files. Below, an example. Asked why users are logged out at random, Claude answers from a stored finding that Redis evicts session keys under allkeys-lru, with no files read.

Image: How Attic works by Nishikanta Ray, MIT.

Attic 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.

Pick it for long investigations that span /compact and new sessions, when you want findings a team can commit and review.

memshare

Shared memory · MCP server and CLI · MIT · any MCP client · npm memshare-mcp 0.7.5, 21 September 2026 · 0 stars.

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). 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."

Pick it to hand what one assistant learned to a colleague on a different agent.

prompt-cache-skills

Cache 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.

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). 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.

Pick it if you run Cline, Roo Code, Continue, OpenCode or Aider from source and suspect caching is off.

Every headline saving was measured by its own authors

Each 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.

Tool Headline What was measured Sample Rerun it yourself
Headroom 57% (55,957 to 24,340) Tool-result tokens, synthetic payload, non-default setting 1 seeded run Yes, offline script
RTK Up to 90% Shell output bytes, raw against filtered Your own rtk gain Yes, on every command
Engram 89.1% Packet against whole file, Engram's own repo 87 files, 1 run Yes, on any repo
cocoindex-code 70% Not stated Not stated No
Attic 34% input, 21% cost Real Claude Code sessions, plugin on against off 1 run per arm Harness yes, repo private
memshare None claimed n/a n/a n/a
prompt-cache-skills 10x List-price arithmetic for a cached prefix None Cache check script

The only outside data point is indirect: in The Complexity Trap, plain observation masking halved SWE-agent's cost on SWE-bench Verified while matching the solve rate of LLM summarization.

A compressor that drops the wrong line fails without an error

A 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).

  • Output that looks like data. In Headroom issue #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%.
  • Line numbers glued to the wrong content. Issue #3545, closed on 30 September after a related fix, showed grep matches fused onto one line's text, which "manufactures false line↔︎content associations".
  • A safety rule that stopped holding. Alexey Vidanov compressed 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.
  • A cheaper call that cost more. One Headroom user reported 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) shipped on 11 August 2026.

Headroom, RTK, Engram and the rest side by side

The 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.

Tool Kind Where it sits Agents Licence Install
Headroom Compressor Proxy, wrapper, library, MCP 18 named, any OpenAI-compatible Apache-2.0 uv tool install --python 3.13 "headroom-ai[all]"
RTK Compressor Shell hook 18 Apache-2.0 (+ BUSL-1.1) brew install rtk
Engram Index, memory Hooks, MCP, IDE extension 8 IDEs Apache-2.0 source build
cocoindex-code Index CLI, skill, MCP Skill or MCP clients Apache-2.0 pipx install 'cocoindex-code[full]'
Attic Memory Plugin Claude Code, Codex CLI MIT claude plugin marketplace add NishikantaRay/Attic, then claude plugin install attic@attic
memshare Shared memory MCP, CLI Any MCP client MIT npm install -g memshare-mcp
prompt-cache-skills Cache fixer Skills that patch harness code 5 open-source harnesses CC BY 4.0, MIT git clone into skills

More tools in this layer turn up among the AI tools developers list and the terminal and shell tools RTK sits beside.

Which one for which agent, team and budget

  • Claude Code or Codex, cache working, shell-heavy sessions: RTK, the rtk-oss build if you want Apache-2.0 only.
  • 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.
  • Large repository, agent reading whole files: cocoindex-code for local semantic search; Engram if you also want its hooks across eight IDEs.
  • Long investigations that outlive /compact: Attic.
  • Sharing what an assistant learned with a teammate: memshare.
  • Cline, Roo Code, Continue, OpenCode or Aider from source: prompt-cache-skills first, since a broken cache costs more than anything a compressor saves.
  • Short sessions: none of them. Attic measured its own index as overhead there, and /clear costs nothing.

New posts by email

About one email a week with what we published. No account needed.

One email to confirm first. Every email has a one-click unsubscribe.

Which of these do you use?

Nobody on Stackness runs RTK yet. Tick what you use and be the first.

Lonny skating the lakeside path, kickflipping onto a bench, grinding it and flipping offStackness gamesPlay Lonny Eagle Amateur Skater 4A pixel art skateboarding game. Signing up opens it straight away.+2 secret games you unlock as you goSign up to play