A Claude Code plugin that lets the agent search its own conversation from before a compaction, so it can get back the details the summary dropped.
When a long session fills its context, Claude Code replaces the conversation with a summary and carries on. Summaries lose things: a port number, who owns a key, which ticket a task is waiting on. The full conversation is still on disk, but as a large raw file the agent has no targeted way to search. backread gives the agent a keyword search over it, and a line after each compaction telling it the search is there.
/plugin marketplace add afterimaginary/backread
/plugin install backread@backread
Yes, in a controlled test run before the plugin was built, with direct questions rather than a live task. On 48 long conversations, each compacted five times, an agent answered questions about what had been said earlier. With a 1,024-token summary plus search, it scored 0.80, against 0.53 for the summary alone and 0.72 for a summary four times the size. On claude-haiku-5-5, the capped keyword search used fewer tokens per question than the bigger summary and cost less per correct answer.
A stronger reader doesn't remove the need. On the 384 questions after the fifth compaction that all three models answered, the summary alone scored 0.42 on claude-haiku-5-5 and 0.43 on claude-opus-5-5; with search, 0.72 and 0.85. On Opus, though, search cost about as much per correct answer as the bigger summary.
The test also found a blind spot: the agent nearly always searched when the summary had left something out, but much less often when the summary gave a wrong answer, and seldom fixed those. The test behind it has the method and every hypothesis, and REPORT.md is the full write-up.
In this real session, the user asked Claude Code to drop some details when compacting, then asked for them afterwards (trimmed):
❯ Before I set up the deploy script: which port does staging listen on, and who owns the deploy key?
⏺ Bash(backread search staging port deploy key owner --transcript ~/.claude/projects/-work-scratch/00000000-0000-4000-8000-000000000001.jsonl)
⎿ …
[L3] user message, 2026-11-27 08:06 UTC
I'm starting a small static site here. A few things to keep in mind, no need to write them down
anywhere: the staging server listens on port 8437, the deploy key belongs to Ines Okafor, …
⏺ Staging listens on port 8437, and the deploy key belongs to Ines Okafor. I didn't have either in my
summary, because you asked me to drop those notes when compacting. I found them by searching the
earlier part of the session.
The plugin has three parts:
-
The
backreadcommand.backread search <words>returns up to 3 excerpts (500 characters max), each with a handle;backread get <handle>prints a record, up to 4,000 characters at a time. It searches the conversation before the last compaction, including tool output and subagents, with the same search code and caps as the test. -
A hook that runs after each compaction and adds one line to the agent's context, naming the command and this session's transcript:
`backread search <words> --transcript ~/.claude/projects/-work-scratch/<session>.jsonl` searches the original conversation that the summary was written from, by keywords, and returns up to 3 short excerpts with their handles.The wording is a plain tool description. In the test, a stronger nudge, warning that the summary might be out of date, cost more without cutting outdated answers.
-
A short skill telling the agent when a search is worth it.
In three trial sessions, the agent searched and answered correctly in two. In the third it said it could search and asked first.
Claude Code's own summary already points to the raw transcript file near its end, so an agent can read it without this plugin. What backread adds is a search over it, instead of a large JSONL file with tool output and subagents mixed in. The test didn't measure the raw-file route.
- Tested on Claude Code 2.1.327. It runs on macOS and Linux and needs Python 3.13 or later, or uv to fetch one.
- Claude Code only. claude.ai and Cowork don't support this kind of plugin.
- Keyword search only.
- One session per folder by default. Without the hook's
--transcript, it reads the newest transcript for the working directory, which may be another session's.
Commands, output and exit codes: docs/cli.md. The plugin and its hook: docs/plugin.md.
When a long agent session runs out of context, the conversation is replaced by a summary and the original stays on disk. The experiment uses the public practice suite of CompactBench: 48 long synthetic working conversations, each compacted five times, with exact-answer questions about what was said. One compactor writes every summary, and a reader model answers each question, one per request, seeing only what its arm allows:
| Arm | The reader sees |
|---|---|
floor |
Nothing |
summary |
The summary at a 1,024-token budget |
summary-big |
A summary at a 4,096-token budget |
search |
The 1,024-token summary, plus a keyword search over the original conversation, described in one neutral sentence |
search-nudged |
The same, plus one sentence saying the summary may be out of date |
ceiling |
The whole conversation |
A search returns at most 3 excerpts of at most 500 characters, and the reader gets at most 3 searches per question, so a search arm sees at most about 1,200 tokens of the original: less than the 3,072 extra tokens summary-big gets. Scoring is CompactBench's own scorer; no judge model is used. The main run asked 1,802 questions in each arm.
Four hypotheses were fixed in PLAN.md before any paid run. Three passed.
| Hypothesis | Verdict | Number |
|---|---|---|
search beats summary on score |
pass | +0.277, 95% interval [0.256, 0.297] |
| Searching fixes left-out information far more than wrong information, because the reader doesn't search when the summary looks complete | pass | When the summary had left the answer out, the reader searched on 91.6% of questions and got 63.5% right; when the summary had given a wrong answer, it searched on 39.7% and got 15.9% right |
| Telling the reader the summary may be out of date lowers stale answers and costs noticeably more | fail | It cost more (9,344 tokens per question against 5,588), but its stale-answer rate came out slightly higher, not lower: 12.5% against 11.4%, a difference within noise |
summary-big closes part of the gap |
pass | 0.724, between summary's 0.526 and ceiling's 0.954 |
The reader knows when something is missing, not when something is wrong: a summary that states an outdated value gives no hint that it needs checking. Search's lead also grows with compaction: after one compaction search and summary-big score about the same, and after the fifth search is well ahead (by cycle).
Case …27718baeca50600b, after the fifth compaction. Excerpts trimmed with …:
Q: Which ticket is OPS-3395 waiting on? correct: OPS-9453
summary 1,024-token summary, no search
→ "Not stated in the conversation" wrong
search same summary, one search: "OPS-3395"
turn 731: USER: Hugo Raman can't move OPS-3395 forward. It's
Blocked, waiting on OPS-9453.
turn 58: … OPS-3395 — Add alerting for the feature-flag service — Hugo Raman — To do
turn 609: … OPS-9453 doesn't need OPS-3395 after all. It's
unblocked and back In progress.
→ OPS-9453 right
The summary kept that OPS-3395 was blocked but dropped what it was waiting on. The gallery has four more, picked by mechanical rules, including the failures: a search that fetched the old value, a confidently wrong summary the reader never checked, and a question the bigger summary won.
The traces of every paid run are committed, so the analysis reruns for free, with no API key:
git clone https://github.com/afterimaginary/backread && cd backread
uv sync
make report # rebuilds every table, chart and number in REPORT.md from the saved traces
git status # nothing changedIt needs uv and takes under a minute. The first run downloads CompactBench's tokenizer file (about 1.7 MB). make offline runs the whole pipeline on 2 cases against fake models, also free.
Running the models again is paid and needs Anthropic API credentials: ANTHROPIC_API_KEY, or a profile from ant auth login. The summaries are committed, so a rerun doesn't need to compact again. Estimate first, then run with a hard cap:
# Free: tokens and dollars per arm for the whole grid into an empty folder (about $40)
uv run python -m backread_exp estimate --runs-dir data/cache/fresh-runs
# Paid: two arms on 3 cases, about $0.11, stopped at $0.25
uv run python -m backread_exp run --model claude-haiku-5-5 --arms summary search \
--cases 3 --runs-dir data/cache/fresh-runs --max-usd 0.25make estimate prices only what isn't in results/runs/ yet, which in a clone is almost nothing, so the estimate above points at an empty folder. data/cache/ is ignored by git.
run prints its estimate before the first call, refuses any request that could take it past --max-usd, and resumes if run again. Every paid call is logged to results/ledger.jsonl, and a project-wide cap of $100 counts that ledger, including the $94 already in it. make report REPORT_RUNS=data/cache/fresh-runs REPORT_OUT=data/cache/fresh-results reports a fresh run without touching REPORT.md. CONTRIBUTING.md lists every command.
$94.16 for the whole project, from the spend ledger:
| Part | Dollars |
|---|---|
| Summaries (480 compactor calls) | $2.94 |
claude-haiku-5-5 grid: main run with pilot, plus a second summary run |
$14.69 |
claude-sonnet-5-5 second-model run |
$21.41 |
claude-opus-5-5 third-model run |
$49.06 |
| Calibration and checks | $6.05 |
Per 1,000 correct answers on the main run, at Anthropic's published prices:
floor |
summary |
summary-big |
search |
search-nudged |
ceiling |
|---|---|---|---|---|---|
| $1.46 | $0.57 | $1.08 | $0.91 | $1.40 | $4.53 |
summary is cheapest per correct answer, but gets far fewer right. floor scores zero yet has a cost per correct answer because questions whose right answer is "not stated" count as correct here but are left out of the score. Among the arms that score higher, search is cheapest.
- Synthetic conversations and direct questions. A real agent in the middle of a task has to notice on its own that it needs something the summary lost, which is harder than being asked.
- One compactor, one reader model for the verdicts. Every summary comes from CompactBench's
sectioned-summaryonclaude-haiku-5-5, and nearly all were cut to fit their budget. A second model,claude-sonnet-5-5, ran a smaller grid with the same shape of result but decides nothing, andclaude-opus-5-5repeated it as an extra after the plan: search scored higher there too. - One kind of search. Keyword search with tight caps; other search or longer excerpts could change the stale-answer results either way.
- Not on CompactBench's leaderboard scale. The reader asks one question per request with its own prompt, so scores aren't comparable to the leaderboard's.
The hypotheses, prompts, seeds and pass conditions are in PLAN.md, tagged plan-frozen before the first paid call; CI fails if anything above its Deviations section changes. REPORT.md has every result with its interval, the full limitations and next steps.
MIT. CompactBench, which generates the conversations, is Apache 2.0, and the committed summaries, traces and excerpts that quote its conversations stay under that license; NOTICE lists them.
Bugs and questions: open an issue. Anything else: hello@afterimaginary.dev.