Skip to content

a-Fig/Accordion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

375 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Accordion

/compact is the naive solution, Accordion is the intelligent one.

See everything your AI agent holds in context β€” and fold it like an accordion instead.

Accordion β€” the context map demo: blocks folding and unfolding while the protected tail stays intact

Your whole context window split in 2 sections. The lower section represents your agents most recent context and is protected against any interference


Accordion is a pi extension that shows you your agent's entire context window at a glance and lets you manage it manually or with intelligence through a conductor.

Accordion's context Map β€” a live pi session rendered as a grid of colored blocks

Why it's different

1. No blocking calls for compaction

your context window is automatically managed for you in the background, keeping you below your limit

2. longer more useful sessions

The relevance of each block is ranked so we only fold bloat, and keep whats important.

3. Cheaper inference costs

Accordion keeps your context window lean, with cache optimizations in mind.

Every long-running agent hits the same wall: the context fills up, and something has to go. Today's answers are dumb and dumber:

  • Compaction blasts your whole history into one lossy summary β€” slow, destructive, all-or-nothing.
  • Sliding windows just drop the oldest tokens β€” the agent simply forgets.
Sliding window /compact skills & memory πŸͺ— Accordion
Keeps old context usable ❌ ⚠️ lossy ⚠️ if retrieved βœ…
Reversible to full detail ❌ ❌ ❌ βœ…
No mid-task stall βœ… ❌ βœ… βœ…
Per-section, not all-or-nothing ❌ ❌ ⚠️ βœ…
You can see and steer it ❌ ❌ ❌ βœ…
No extra infra (no vector DB) βœ… βœ… ❌ βœ…

The proof β€” early, but pointed

Accordion ships with a catalog of interchangeable Conductors. The strongest so far, Thermocline, scores each block relevance to the most recent context using the attention from a 500M parameter model as a proxy.

In a test run on SlopCodeBench (a long-horizon coding benchmark), Thermocline at a 100k-token budget outperformed naive compaction with the same constrained context budget. Both used deepseekV4Pro.

Conductor Context Budget Score Checkpoints reached
Thermocline 100k 83.3% 5 / 6
naive compaction 100k 33.3% 2 / 6

⚠️ Read this as a signal, not a guarantee. It's a single hackathon-scale run on a subset of the problems β€” not a published benchmark. Broader, repeatable evaluation is on the roadmap.

How it works

The context Map is the whole window at a glance: one square per block, sized by token weight (a dice face, 1–6), colored by kind β€” user messages, assistant responses, thinking, tool calls, and tool results each get their own hue. Bright = live; recessed and hatched = folded.

Three hands share those controls:

  • You β€” fold, unfold, pin, and peek by hand. Your overrides always win.
  • The agent β€” reaches back to unfold or pin context it needs mid-task, or recall a folded block as a tool result (like read_file) without changing what's standing in context.
  • The Conductor β€” an automatic strategy that, between turns, folds what's gone cold and unfolds what's becoming relevant. Collaborative by default; an exclusive conductor you approve can take over specific controls, and detach is always your kill switch.

Every block is Full, Folded (shown as a short tagged summary), or Pinned (locked open).

Attention conductor view β€” each block tinted by how much the working tail still attends back to it
Folded blocks are shown with dull colors

Folds nest: cold turns fold into groups, groups into bigger groups, so a session of thousands of turns stays small enough to fit and complete enough to recover. And the recent past is always safe β€” the most recent ~20k tokens are a protected working tail the agent reasons over at full fidelity (the thick-bordered box below the fold line).

β†’ Capability matrix, full walkthrough, and the deep spec: VISION.md

What works today

  • βœ… Desktop app (Tauri + SvelteKit): the Map view, token budget, inspector, protected working tail.
  • βœ… Live link to a running pi session, with auto-discovery.
  • βœ… Opt-in live steering β€” apply your fold plan to what the agent is shown.
  • βœ… Reversible, provider-safe folding with deterministic {#code FOLDED} digests the agent can ask to unfold.
  • βœ… Involvement locks β€” exclusive conductors, the consent gate, freeze-on-detach, and agent recall.
  • βœ… The Conductor β€” automatic fold/unfold between turns, based on context.
  • βœ… LLM-generated summaries, computed once and cached.
  • βœ… Read-only browsing of saved Claude Code transcripts.

Honest about what's not there yet: no agent-driven pinning, no hierarchical (nested) groups, no replay. That's the build ahead.

Roadmap

  • Core fold/unfold engine β€” reversible, tool-pair safe
  • The separate window β€” desktop app: Map view, budget, inspector
  • Live link to pi + auto-discovery, opt-in steering
  • Agent-driven unfold + recall, involvement locks
  • LLM-generated summaries, computed once and cached
  • The Conductor β€” automatic fold/unfold between turns
  • Hierarchical folding for million-turn sessions
  • Agent-driven pin
  • Replay β€” scrub how context evolved across a session
  • Better conductors β€” research, develop, and test stronger context strategies
  • Expand accordion beyond pi

Quick start

Part 1 β€” Browser (no Rust, no desktop app)

pi install npm:@a-fig/accordion

restart pi if it is already running, then inside of pi run:

   /accordion                                                                       

That's it, assuming you have pi


Part 2 β€” Desktop app (Optional - full feature set)

The desktop app adds multi-session discovery (switch between running pi sessions from a sidebar), conductors that require local model resources, and the /accordion command that foregrounds the right session automatically. It requires Node 20+ and Rust.

Prerequisites: install Node 20 LTS and Rust via rustup, then follow the one-time platform setup at https://v2.tauri.app/start/prerequisites/ (WebView2 + MSVC on Windows, Xcode CLT on macOS).

1. Clone and install:

git clone https://github.com/a-Fig/accordion.git
cd accordion/app && npm install

2. Register the extension with pi β€” add to ~/.pi/agent/settings.json:

{ "extensions": ["<absolute-path-to-repo>/extension/accordion.ts"] }

3. Launch the desktop app:

npm run tauri dev   # opens the native window; hot-reloads on save

4. Run pi in any project. It appears in Accordion's Sessions sidebar within ~1s. Click it (or run /accordion in that terminal) and its context populates live.

Contributing

An experiment in context engineering β€” contributions, ideas, and benchmarks welcome. Setup, the quality gate, and platform gotchas are in CONTRIBUTING.md.

Our main frontier right now is better conductors: researching which context actually matters, developing stronger strategies, and testing them against real sessions. We're not chasing a long tail of mediocre ones β€” the goal is one to three conductors that genuinely hold up. A conductor is a single class with one method β€” conduct(view) β†’ Command[] β€” and one registration line to appear in the app. Strategies can range from simple oldest-first folding to scoring each block's relevance with a small model. If you have a theory about what an agent should keep and what it can let go, that's the surface to prove it β€” and the place where outside help is most valuable right now.


The north star: your agent's memory should be something you can see and steer β€” not a black box that silently forgets.

πŸ† Β Built at the AI Hackathon 2026 @ UC Berkeley β€” a winning project.

Tyler Darisme Β Β·Β  Aaditya Desai Β Β·Β  Sheel Shah Β Β·Β  Thy Tang

πŸͺ—

About

πŸ† AI Hackathon 2026 @ UC Berkeley Intelligent context management for developers

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors