Accordion
this page 0/ 0 tok
GitHub

A context manager for coding agents

/compact is the naive solution.

When your agent's context fills up, compaction crushes the whole session into one lossy summary. The agent stalls while it happens, and nobody can undo it. Accordion folds context one block at a time. Every fold is reversible, and the agent can pull back anything it needs by code.

pi install npm:@a-fig/accordion

A pi extension. MIT. Then run /accordion in pi.

context window 0 tok
Blocks 317–332 of a real 982-block pi session. Digests are Accordion's own output. Click a block to fold or unfold it.

One summary, or 982 folds you can undo.

Same session, same pressure. Compaction replaces everything with a single summary the model writes once. Accordion swaps each block for a short tagged digest and keeps the original.

/compactwhole session, one shot
recoverable
982 / 982
agent waits
—
accordionper block, between turns
recoverable
982 / 982
context
—
/compactAccordion
GranularityThe whole session, at onceEach block on its own
UndoNone. The original is gone from the model's view for good.Every fold. The original is kept, byte for byte.
Agent stallBlocks on an LLM call mid-taskNone. Folds apply off the critical path, in under a millisecond.
Reaching backImpossibleunfold or recall by the code in the tag
Recent workSummarized with everything elseThe newest ~20k tokens are never folded
VisibilityHappens off-screenEvery block on one map, live

Your whole context window, on one screen.

One square per block, in conversation order. Color is the kind of block and the dice face is its weight. The thick box at the bottom is the protected tail: the agent's working memory, which nothing folds.

user reply thinking tool call tool result folded

You

Fold, unfold, pin, or rewrite any digest by hand. Your override always wins.

The agent

Sees {#hs8v8v FOLDED} and calls unfold or recall with that code when it needs the original.

A conductor

Folds for you between turns, under the same rules as your hand. Detaching it is always your call.

Five strategies, all bound by your rules.

A conductor decides what folds. It proposes edits between turns, and every edit is checked by the same code that checks yours, so it can never do anything you couldn't. Pick one from the header, or leave it on None and steer by hand.

  1. thermoclinebenchmark

    A 500M-parameter probe scores how much recent context still attends to each block. That decides what compresses first, and LLM summaries decide how far. A hard budget sits on top, and if your cap can't be met it says so.

    out of process · locks your steering · repo checkout
  2. triptych

    Three bands by age. The newest third stays raw, the middle turns file reads into tree-sitter skeletons (signatures kept, bodies dropped), and the oldest third is summarized. The skeletons can be recalled.

    out of process · exclusive · repo checkout
  3. doorman

    Catches a huge fresh tool result on its way out and folds it before the model ever pays for it in full. A proof of concept.

    in process · collaborative
  4. handoff

    /handoff without leaving the session. It writes a handoff document, folds everything before it, and keeps going.

    in process · exclusive
  5. compaction-naive

    /compact, rebuilt as a conductor. It's the baseline everything else is measured against.

    in process · exclusive

Lab notes

One run of thermocline against naive compaction on a long-horizon coding benchmark, with the same model and the same context budget.

benchmark
SlopCodeBench, subset
model
DeepSeek V4 Pro, both arms
context budget
100k tokens, both arms
runs
1 per arm
metric
checkpoints reached, of 6
thermocline 83.3%
compaction-naive 33.3%

What this shows

Under the same tight budget, picking what to fold by relevance got further than summarizing everything, in this run.

What it doesn't

It's one hackathon-scale run on a subset of the problems, not a published result. Broader, repeatable evaluation is next on the roadmap.

UC Berkeley AI Hackathon 2026 · 2nd place, best token compression

Two commands.

  1. 1
    pi install npm:@a-fig/accordion

    Restart pi if it's already running.

  2. 2
    /accordion

    Run it inside pi. It prints a local URL that stays the same every time. Open it and you'll see every live session on the machine.

  3. 3

    Folding starts off. Accordion only watches until you flip the toggle, then you steer by hand or pick a conductor.

A desktop app (Tauri) adds read-only browsing of saved Claude Code transcripts. Setup is in the README. The design is in VISION.md.