Skip to content

Session resume drops ~18k tokens of context with no compact_boundary #35358

Closed as not planned

Description

@kzahel

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.

Activity

  1. github-actions commented on Apr 14, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  2. github-actions commented on Apr 23, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  3. locked as resolved and limited conversation to collaborators on Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions