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

  1. There are no compact_boundary entries anywhere in the session file, so auto-compaction did not occur (or was not recorded)
  2. cache_read_input_tokens dropped 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
  3. The session JSONL contains progress entries (type hook_progress, e.g. PostToolUse:Read, PostToolUse:Write) that have parentUuid values linking them as siblings of tool_result user messages — both are children of the same assistant message. This creates forks in the message DAG
  4. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗