resume/forkSession fails with 400 on sessions containing tool_use blocks

Resolved 💬 1 comment Opened Apr 1, 2026 by ArinYaldizciyan Closed Apr 1, 2026

Description

When using the Agent SDK's resume option to resume a session that contains tool_use blocks, the API returns a 400 error:

cache_control cannot be set for empty text blocks

or

messages: text content blocks must be non-empty

Reproduction

  1. Create a session via query() that uses tools (Read, Edit, Bash, etc.)
  2. Let it complete
  3. Resume with query({ prompt: 'follow up', options: { resume: sessionId } })
  4. API rejects with 400

Simple text-only sessions resume fine. Only sessions with tool_use blocks are affected.

Root Cause

The JSONL session transcript contains empty text blocks ({"type": "text", "text": ""}) that appear between tool_use blocks. When the SDK replays the conversation with cache_control annotations, the API rejects these empty blocks.

Workaround

Sanitizing the JSONL file before resuming — removing content blocks where type === "text" and text is empty or whitespace — resolves the issue.

Environment

  • @anthropic-ai/claude-agent-sdk v0.2.88
  • Claude Code CLI (latest)
  • macOS, Node.js v24.1.0

Related Issues

  • #2203, #24662, #23440, #14132 (all same family)
  • agent-sdk-typescript #89

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗