Rewind "Summarize up to this point": turns completed during the in-flight summarization are silently dropped, and /context then reports stale pre-compact usage
Summary
In a long session (~856k/1M tokens) with background Task agents running, invoking Rewind → "Summarize up to this point" produced two coupled failures:
- Silent turn loss (race condition): the summarization ran asynchronously for ~4 minutes. During that window, two background agents completed; their
task-notificationturns were delivered and the assistant replied to each (all visible in the terminal). When the summarization landed, those exchanges vanished from both the terminal transcript and the model context — no warning, no error. The turns had durable side effects (git commits made by tool calls in the replies), so the model's context now omits actions it actually performed. - Stale
/contextafter a successful compact: compaction actually succeeded, but/contextrun 14s and again ~110s after the compact boundary still reported the pre-compact numbers (856.2k / 1M, 86%; "Messages: 839.7k"), which made it look like no compaction had occurred at all.
Environment
- Claude Code v2.1.202 (CLI,
entrypoint: cli) - macOS guest VM (Tart virtualization), darwin 25.5.0
- Model: claude-fable-5 with 1M context window
- Session state at repro: ~856k tokens (86%), 3 background agents launched via the Task tool still running
Repro narrative
- Long-running session reaches ~856k/1M tokens; 3 background Task agents in flight.
- Two agents complete; their task-notification turns arrive and the assistant replies to each (user sees both exchanges).
(Note: per the transcript, the notifications actually arrived ~2.5 min after the user had already started step 3 — the point is they were fully rendered and answered while the summarize was still running.)
- User opens Rewind, selects a checkpoint from ~2h earlier, and chooses "Summarize up to this point" (with custom summary instructions).
- Summarization runs in the background for ~4m11s; meanwhile the main loop keeps dequeuing and answering task-notifications.
- Summarization completes → terminal redraws without the notification exchanges; no summary message is visible to the user;
/contextstill shows 856.2k (86%). - User concludes "messages disappeared and compaction failed".
Forensic findings (session JSONL, ~/.claude/projects/<project>/<session-id>.jsonl)
Timeline reconstructed from entry timestamps (UTC):
| time | event |
|---|---|
| 18:36:42 | checkpoint node a43e959b (system turn_duration) — the rewind point the user later selected |
| 20:49:10 | last assistant turn before the operation completes; tail node 02de9921 |
| ~20:50:13 | user triggers "Summarize up to this point" (= boundary timestamp minus durationMs) |
| 20:52:51 | agent #1 task-notification enqueued (queue-operation) and processed; assistant replies — parented to 02de9921 |
| 20:53:38–20:54:17 | agent #2 notification processed; assistant replies — same branch |
| 20:54:24.774 | system entry subtype: "compact_boundary" written, followed by a user entry with isCompactSummary: true (~11k chars). |
| 20:54:38 | /context → 856.2k / 1M (86%), Messages 839.7k |
| 20:56:14 | /context again → still 856.2k (86%), Messages 839.7k |
| 20:56:57 | next real assistant API call usage: input_tokens: 7822, cache_creation: 5660, cache_read: 108702 ≈ 122k actual context; subsequent turns ~125k |
Key fields of the compact_boundary entry:
{
"subtype": "compact_boundary",
"parentUuid": null,
"logicalParentUuid": "a43e959b-…", // the 18:36 checkpoint the user selected
"compactMetadata": {
"trigger": "manual",
"preTokens": 858844,
"postTokens": 30147,
"messagesSummarized": 817,
"durationMs": 251396, // ≈ 4m11s in flight
"cumulativeDroppedTokens": 828697,
"preservedSegment": {
"headUuid": "51153d6d-…", // first message after the checkpoint (18:43)
"anchorUuid": "a3b6245b-…", // the isCompactSummary message
"tailUuid": "02de9921-…" // last turn at operation START (20:49:10)
}
}
}
What this shows:
- The preserved segment was snapshotted when the operation started (
tailUuid= the 20:49:10 node). The turns generated during the 4-minute in-flight window (20:52:51 → 20:54:17) chain off that same node in the old branch. When the boundary + summary + preserved chain became canonical, those turns were orphaned — still physically present in the JSONL as a dead branch, but absent from the active conversation and the redrawn terminal. Nothing was deleted from disk; nothing was surfaced to the user either. - Compaction itself worked: 858,844 → ~122k actual tokens on the next API call. The summary message exists in the transcript (
isCompactSummary: true, parented to the boundary; the boundary'slogicalParentUuidcorrectly points at the user-selected checkpoint). /contextdid not reflect it: two invocations at +14s and +110s after the boundary still reported the pre-compact estimate (856.2k total / Messages 839.7k) — while the very same UI had already redrawn the transcript in its post-compact shape. The stale readout is what convinced the user that the whole operation had silently failed.
Expected behavior
- Turns that complete while a rewind-summarize is in flight must not be silently discarded. Either (a) hold the notification queue while the summarization runs, (b) re-anchor/append turns that landed mid-flight onto the compacted chain, or (c) at minimum warn: "N turns completed during summarization and were dropped (recoverable via rewind)".
/contextimmediately after a compact should report the post-compact context (or explicitly say it is an estimate pending the next request).- Nice-to-have: the Rewind menu could warn when background Task agents are running, since their completion notifications are exactly what races with the summarize.
Actual behavior
- Two completed-agent notification turns + assistant replies silently vanished from terminal and context (orphaned branch in JSONL); their durable side effects (git commits) remain, unknown to the model.
/contextreported pre-compact usage (856.2k/86%) at least twice after a compact that had actually reduced the context to ~122k, so the user had no way to tell the compaction had succeeded.
🤖 Generated with Claude Code
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗