Session resume drops ~18k tokens of context with no compact_boundary
Resolved 💬 2 comments Opened Mar 17, 2026 by kzahel Closed Apr 14, 2026
Observed in
claude-agent-sdk 0.2.76
What happened
A session was resumed mid-conversation via the SDK's resume option. The agent exhibited loss of context, repeatedly forgetting work done earlier in the session.
- Before resume, the last assistant message reported total input tokens (
input_tokens + cache_read_input_tokens + cache_creation_input_tokens) = 48,821 - After resume, the first assistant message reported 30,751 — a drop of ~18,000 tokens (~37% context loss)
Key observations from the JSONL
- There are no
compact_boundaryentries anywhere in the session file, so auto-compaction did not occur (or was not recorded) cache_read_input_tokensdropped from 48,520 back to 8,619 (the same value seen on the very first assistant message of the session — i.e., the base system prompt + tools). This indicates the SDK rebuilt the context from scratch on resume rather than continuing from the existing cache- The session JSONL contains
progressentries (typehook_progress, e.g.PostToolUse:Read,PostToolUse:Write) that haveparentUuidvalues linking them as siblings oftool_resultuser messages — both are children of the same assistant message. This creates forks in the message DAG - No user-initiated rewinds or edits occurred — the DAG forks were created entirely by the SDK's internal bookkeeping
Expected behavior
Resumed session should have roughly the same context size as before the resume (minus any intentional compaction, which should produce a compact_boundary entry).
Actual behavior
~37% of context was lost silently on resume. The agent could no longer recall prior conversation content.
Reproduction
Hard to reproduce on demand — observed once so far. The session had multiple tool uses with PostToolUse hooks configured, creating hook_progress entries in the JSONL that fork the message DAG.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗