claude-code - 💡(How to fix) Fix Resuming old sessions returns API Error: 500 status code (no body) — caused by empty thinking and tool_result blocks persisted to JSONL [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#58827Fetched 2026-05-14 03:38:29
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

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)..."

Root Cause

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:

Code Example

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)..."
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Resuming old sessions returns API Error: 500 status code (no body) — caused by empty thinking and tool_result blocks persisted to JSONL [1 comments, 2 participants]