Context visualization & intelligent context management for coding agents
/compact
summarizes when fullwaiting on a summary…
0:00
Accordion
folds block by blockThe context problem
Every coding agent runs on a limited context window. Most of it fills with things the agent doesn't need, and the signal drowns in the noise.
The promise
-
01
No blocking calls for compaction
/compact: agent waited 2 min 30 sAccordion: 0 s
-
02
Longer, more useful sessions
/compact: 0 of 598 old blocks recoverableAccordion: all 982 recoverable
-
03
Cheaper inference
Accordion: 84.9k tokens per call instead of the full 132.3k
pi install npm:@a-fig/accordion
A pi extension. MIT.
Context visualization
Accordion shows your agent's whole context window on one screen: one square per block, in conversation order.
- Color → block type
-
- User message
- Thinking
- Tool call
- Tool result
- Assistant response
- Dice face → number of tokens in the block
- Dull → folded
The thick box at the bottom is the protected tail: the newest ~20k tokens, which are never folded.
99,921 / 100,000
Hover a square to see what it is. Click one to fold it.
Every fold is reversible
A folded block collapses to a short digest, tagged with a unique code. Nothing is ever deleted; folding only changes what the agent is shown.
TOOL RESULT6.2k tokens
Read 240 lines from parser.ts: full source of the tokenizer, exports, and inline tests…
{#a3f2c9 FOLDED}
read → parser.ts, 240 lines · exports tokenize(), parse()
0.1k tokens
unfold("a3f2c9")- Brings the block back into the agent's context.
recall("a3f2c9")- Returns the full block once, as a tool result. The view doesn't change.
User messages and tool calls are never folded.
How the fold tag works
{#<code> FOLDED} <digest>
- <code>
- Six characters of base36, a hash of the block's id. The same block gets the same code in every session.
- <digest>
-
A short summary whose shape depends on the block type:
{#hs8v8v FOLDED} thought · ~154 tok · Alright, let's keep going. We just swept F5-F8 (all misses), credits at 45, 2 s…{#hi99jw FOLDED} F5-F8 all misses! 45 credits. Let me continue - **row G** (G1-G4 unknown):{#2jpyiu FOLDED} bash → 50 lines, ~308 tok · Waiting for your turn... - Who writes tags
- Only Accordion. A digest you write yourself has no tag, so the agent can't undo your edit.
function foldCode(id) {
let h = 0x811c9dc5; // FNV-1a 32-bit
for (let i = 0; i < id.length; i++) {
h ^= id.charCodeAt(i);
h = Math.imul(h, 0x01000193);
}
return (h >>> 0).toString(36).padStart(6, "0").slice(-6);
}
The conductor
Context management strategies. A conductor edits the context automatically, between the agent's turns.
- 01The agent takes a turn
- 02The conductor reads the context
- 03Folds & unfolds blocks(edits to context)
↺ repeats automatically
Strategies range from simple FIFO folding to harvesting attention from a 500M-parameter model to score each block's relevance.
Scores how relevant each block still is using attention from a 500M-parameter model, and compresses the least relevant first. Keeps the session under a hard budget.
The proof
Accordion's conductor outperforms naive compaction by 2.5× on SlopCodeBench, a long-horizon coding benchmark.
SlopCodeBench subset · DeepSeek V4 Pro · 100k-token budget · 1 run each
2nd place, best token compression · UC Berkeley AI Hackathon 2026
What's next for Accordion
-
Develop, test, and ship better conductors
Improve benchmark performance · Use data from recall for training · Research a perplexity-based conductor
-
Make it easy for anyone to build conductors
-
Bring Accordion to more harnesses
Vibe, OpenCode, Claude Code, Codex
Today: pi