cd /news/ai-agents/show-hn-compaction-for-million-token… · home › topics › ai-agents › article
[ARTICLE · art-178536] src=github.com ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Show HN: Compaction for million-token agent sessions, with benchmarks

A new compaction method called vcc-hybrid adds a model-written state index to a rule-based summary so agents can retain key decisions across million-token sessions, according to benchmark results published in the project's GitHub repository. The repository reports that default pi-vcc answered "not stated" 2,575 times when the answer was in the conversation, and 2,234 of those came from question batches where the agent never consulted the source. The method rewrites the index at each compaction with a 32,000-character (about 8K token) budget, and all measurements were run in Pi against Pi's default summary and pi-vcc using DeepSeek V4.1 Flash at low effort across 48 conversations, without comparison to Claude Code's or Codex's compaction.

recommendation

Pair a rule-based compaction summary with a model-rewritten state index capped at 32,000 characters, one line per topic citing its source message number, so agents can answer from the index or open the cited message instead of searching.

more in playbook: Designing agent systems
read8 min views7 publishedNov 30, 2026
Show HN: Compaction for million-token agent sessions, with benchmarks
Image: Michielbdejong (auto-discovered)

A method for compacting agent conversations: it adds a model-written state index to a rule-based summary. This repository contains the method's benchmark results and a Pi extension for trying it.

When a conversation outgrows the context window, the agent shortens older messages to make room. This is compaction. Claude Code, Codex and Pi have a model write a summary by default. The summary reads well, but details it leaves out are hard to get back.

VCC uses rules to organize conversation logs and lets the agent look up the original messages. Inspired by that approach, pi-vcc builds a summary without a model call. If the summary leaves out an answer, though, the agent has to recognize that it needs to look. On CompactBench Practice, default pi-vcc answered “not stated” 2,575 times when the answer was in the conversation. Of those, 2,234 came from question batches in which the agent never consulted the source.

Even when the agent searches, which messages it finds matters. A search for the release date might turn up the original Friday plan but miss the message postponing it to Monday. The agent could then give an outdated answer despite having checked the source. vcc-hybrid records the current decision alongside the summary, with a reference to the message that supports it. The agent can answer from that record or go straight to the decision without having to find it again by search.

vcc-hybrid keeps the rule-based summary and adds a state index next to it. The index is a list with one line per topic: the current state and the number of the source message it is based on. At each compaction a model reads the previous index and the messages being compacted, and rewrites the whole index.

Say the team first planned a Friday release, then postponed it to Monday in message 412. The index would read:

Release date — moved to Monday; Friday plan cancelled (#412)

Asked "When is the release?" after compaction, the model can answer from this line. If it needs more detail, it opens message 412.

Model summary (Claude Code, Codex, Pi default) Rule-based summary ( pi-vcc ) Rule-based summary + state index ( vcc-hybrid )
How the summary is made A model writes it Extracted by rule Summary extracted by rule; index written by a model
Model call at compaction Yes No Yes, to write the index
What holds now Up to the summarizing model Not marked One line per topic
Compacted messages Replaced by the summary Searchable Searchable, or opened by the number in the index
  1. Older messages are summarized by rule, without a model call. Recent conversation is left uncompacted.
  2. A model reads the previous index and the messages compacted this time, and rewrites the whole index with a budget of 32,000 characters (about 8K tokens).
  3. When answering, the model sees the rule-based summary, the index and the recent conversation. If a missing detail could change the answer, it opens a cited message or searches the source.

See the method for details.

All measurements were made in Pi, against Pi's default summary and pi-vcc. We did not compare with Claude Code's or Codex's compaction. The three benchmarks measure different things; their scores should not be combined. See the evaluation design.

Each of 48 conversations was compacted at the end of each round, then tested on earlier details. We ran each condition three times with DeepSeek V4.1 Flash at low effort. At first compaction the conversations were only about 26–29K tokens long, so most of the conversation stayed uncompacted at default settings.

Setting Arm Run 1 Run 2 Run 3 Mean /100 Recall calls Compaction cost Answer cost
Default Pi 87.36 86.58 86.69 86.88 0 $1.39 $3.75
Default pi-vcc 72.01 72.11 74.03 72.72 2,819 $0 $14.54
Default vcc-hybrid 93.75 93.94 93.86 93.85 953 $2.17 $8.83
Everything compacted Pi summary only 77.66 78.95 76.82 77.81 0 $1.52 $0.84
Everything compacted pi-vcc 90.64 90.20 91.02 90.62 36,041 $0 $33.28
Everything compacted Index only 90.64 89.63 88.70 89.66 1,881 ($1.84) $1.95
Everything compacted vcc-hybrid 92.00 90.40 89.84 90.75 2,285 $1.84 $2.85

Recall calls and estimated costs are per 48-conversation run, averaged over the three runs at common off-peak prices. The parenthesized $1.84 is the cost of building the reused index, not a new charge for the index-only arm.

The hybrid had the highest mean score at default settings. With everything compacted, it scored just 0.13 points above pi-vcc but made about 1/16 as many recalls at about 1/7 of the combined compaction and answer cost. Analysis by condition and source data

Each arm resumed 22 unfinished repairs nine times per task with GPT-6.1 Terra at medium effort. Each metric uses six resumes per task (132 per arm); the eight-work-response checkpoint and final outcomes use different combinations of runs. This tests a single compaction before resuming, not repeated compaction during a long task.

Arm Pass within 8 work responses Final pass Responses/resume Recalls/resume Est. cost/resume
Full history (uncompacted) 118/132 (89%) 124/132 (94%) 7.8 0 $0.026
Pi summary 100/132 (76%) 123/132 (93%) 10.7 0 $0.031
pi-vcc 104/132 (79%) 121/132 (92%) 11.3 1.2 $0.027
vcc-hybrid 112/132 (85%) 121/132 (92%) 9.2 0.4 $0.032

The hybrid passed 85% of resumes within the official eight-work-response limit, but its pass-rate comparisons with Pi summary and pi-vcc did not meet the corrected significance threshold. Without a response limit, it finished in fewer responses on average than either of the other compacted arms. Per-task results and paired tests

Each arm ran all 35 million-token conversations once with GPT-6.1 Terra at medium effort. Each conversation was compacted ten times before the agent answered 20 questions.

Arm Overall score Recalls/question Input tokens in first answer request after compaction
Pi default 0.436 0 25,245
pi-vcc 0.498 3.18 26,071
vcc-hybrid 0.540 1.24 33,750
Arm Est. cost/compaction Time/compaction Est. answer cost/question Answer time/question
Pi default $0.125 72 s $0.0100 5.8 s
pi-vcc $0 0.08 s $0.0143 14.3 s
vcc-hybrid $0.150 118 s $0.0169 9.8 s

The hybrid outscored Pi default on 31 of 35 conversations. It outscored pi-vcc on 22, which did not meet the sign-test threshold. Compaction took longer than with pi-vcc, but the hybrid made fewer recalls and averaged 9.8 rather than 14.3 seconds per answer. Category scores and paired comparisons

The method is available as a Pi extension. If pi-vcc is installed, remove it first. With both installed, the extension warns at startup.

pi install git:github.com/choam2426/vcc-hybrid
  • Automatic compaction and /compact write a summary and state index./compact keep:N leaves the last N user turns uncompacted; for example,/compact keep:2 leaves two.
  • Text after /compact , such as/compact focus on the deployment constraints , tells the writer what to emphasize in the index.
  • /vcc-hybrid state shows the index./vcc-hybrid recall <query> searches compacted messages; the model usesvcc_hybrid_recall .

The writer uses the current session's model and thinking level unless you override them in global or project settings.json:

{
  "vccHybrid": {
    "model": "openai/gpt-6.1-terra",
    "thinking": "low"
  }
}

The amount of recent conversation left uncompacted scales with Pi's compaction.keepRecentTokens, including model-specific settings. Index writing runs during compaction, not in the background. See one compaction, failure handling and trade-offs.

mise install
mise exec -- npm ci --ignore-scripts
mise exec -- npm run typecheck
mise exec -- npm test
mise exec -- npm run pi:vanilla -- --version
mise exec -- npm run pi:vcc -- --version
mise exec -- npm run bench:practice -- --dry-run

Both version checks use Pi 1.6.0 from the lockfile. pi:vanilla loads no extension; pi:vcc loads only @sting8k/pi-vcc 0.12.0. The bench adapter connects the hybrid to the Pi runner. The dry run checks the compaction, recall and grading path on one case with a mock model. It downloads data and scorer dependencies on first use but makes no paid model calls. Mock scores are not performance results. Verification details distinguish unit tests, session replay and real-model tests.

The code is MIT. extension/vcc/ derives from pi-vcc by sting8k and retains its MIT notice. CompactBench Practice data are Apache-2.0. BEAM result data are CC BY-SA 4.0. Code repair results use Compact-Bench; its own contributions are Apache-2.0 and upstream material retains its own terms.

── more in #ai-agents 4 stories · sorted by recency
── more on @vcc-hybrid 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-compaction-f…] indexed:0 read:8min 2026-11-30 · —