Resuming old sessions returns API Error: 500 status code (no body) — caused by empty thinking and tool_result blocks persisted to JSONL
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Old sessions (any non-trivial size) fail to resume with API Error: 500 status code (no body). New chats work fine. After investigating the on-disk .jsonl transcripts, the root cause is that Claude Code persists content blocks the Anthropic API rejects when replayed on resume:
Empty signed thinking blocks. Every assistant turn in affected sessions contains a thinking content block with "thinking": "" (empty string) plus a long valid-looking "signature". Investigated three failing sessions — 346, 147, and 161 such blocks respectively, zero non-empty thinking blocks. My ~/.claude/settings.json had alwaysThinkingEnabled: true during these sessions.
Empty tool_result content. When the resumed assistant calls ToolSearch for a deferred tool that no longer exists in the current environment (e.g. KillShell), ToolSearch returns a tool_result with empty content (content_len = 0). The very next API request fails with the same 500-no-body error.
The two issues compound: stripping the empty thinking blocks lets the session resume for one turn, after which ToolSearch produces an empty tool_result and the next request fails.
What Should Happen?
Suggested fixes
Never persist thinking blocks with empty thinking text. Either store the full thinking text, or convert to redacted_thinking type with the signature, or omit the block entirely from the saved transcript.
Make ToolSearch always return non-empty content (e.g., "No tools matched query: ..." when there are no matches), or ensure the harness never emits a tool_result with empty content.
Server-side: arguably the 500 should be a 400 with a body describing which content block was invalid. The "500 no body" makes this very hard for users to diagnose.
Error Messages/Logs
Evidence (sample from one affected session)
line 7 assistant content_block_types=['thinking'] ← thinking="", signature=<464 chars>
line 8 assistant content_block_types=['tool_use'] ← parentUuid points to line 7
line 9 user content_block_types=['tool_result']
After stripping empty thinking lines and rethreading parentUuid, the session resumes for one turn, then:
line 2874 assistant tool_use ToolSearch { "query": "select:TaskOutput,KillShell" }
line 2875 user tool_result content_len=0 ← empty
line 2876 assistant text "API Error: 500 status code (no body)..."
Steps to Reproduce
Have alwaysThinkingEnabled: true in user settings.
Use Claude Code for a while — let any session grow past a few hundred KB of .jsonl.
Quit, return, try to resume that session → API Error: 500 status code (no body) immediately.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.50
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗