[Bug] Anthropic API Error: Invalid tool_result block without corresponding tool_use
Bug Description
Summary
Claude Code Web incorrectly shows "Credit balance too low" despite account displaying ~$1000 in available credits. When attempting to transfer the session to CLI as a workaround, a different error occurs: API 400 error about unexpected tool_use_id in tool_result blocks, making the CLI session completely unusable.
Impact
- Severity: High
- Status: Ongoing, no workaround found
- Affected Features: Claude Code Web, Session Transfer to CLI
Expected Behavior
- Credit Balance: With ~$1000 in available credits, Claude Code Web should function normally without credit balance errors
- Session Transfer: When transferring a session from Web to CLI using the "Open in CLI" button, the session should continue working in the CLI environment
Actual Behavior
Part 1: Web Interface
- Claude Code Web displays error: "Credit balance too low"
- Error persists despite account showing nearly full $1000 credit balance
- Repeated attempts to continue working result in the same error
Part 2: CLI After Transfer
- After clicking "Open in CLI" to transfer the session
- Every command/prompt results in API 400 error, regardless of input
- Error message indicates malformed tool result blocks
Steps to Reproduce
- Start a session in Claude Code Web
- Work on a project for an extended period (this was the first long-running session in Web)
- Observe "Credit balance too low" error appearing
- Verify account still shows ~$1000 in available credits
- Click "Open in CLI" button to transfer session to command line
- Attempt to run any command in the CLI
- Observe API 400 error on every command
Error Details
Web Error
Credit balance too low
(Despite account showing ~$1000 available)
CLI Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.2.content.0: unexpected `tool_use_id` found in `tool_result` blocks: toolu_01AeyvCRzKyC6aNziTmPiP3G. Each `tool_result` block must have a corresponding `tool_use` block in the previous message."},"request_id":"req_011CVBRedWjq43rbSr8zemCp"}
Request ID: req_011CVBRedWjq43rbSr8zemCp
Additional Error Logs
<details>
<summary>Click to expand full error stack traces</summary>
[
{
"error": "Error\n at bw (/$bunfs/root/claude:59:1142)\n at <anonymous> (/$bunfs/root/claude:64:10074)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at spawnSync (unknown)\n at spawnSync (node:child_process:226:22)\n at lTT (/$bunfs/root/claude:94:1303)\n at uH (/$bunfs/root/claude:94:3608)\n at read (/$bunfs/root/claude:1628:4607)\n at request (/$bunfs/root/claude:66:2146)\n at processTicksAndRejections (native:7:39)\n at spawnSync (unknown)\n at spawnSync (node:child_process:226:22)\n at lTT (/$bunfs/root/claude:94:1303)\n at uH (/$bunfs/root/claude:94:3608)\n at read (/$bunfs/root/claude:1628:4607)\n at read (/$bunfs/root/claude:2147:17417)\n at tokens (/$bunfs/root/claude:2741:17132)\n at tokens (/$bunfs/root/claude:2741:18322)",
"timestamp": "2025-11-16T10:38:33.311Z"
},
{
"error": "Error\n at bw (/$bunfs/root/claude:59:1142)\n at <anonymous> (/$bunfs/root/claude:64:10074)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:66:2146)\n at processTicksAndRejections (native:7:39)",
"timestamp": "2025-11-16T10:38:33.351Z"
},
{
"error": "Error: Failed to fetch from remote origin: fatal: refusing to fetch into branch 'refs/heads/claude/di-migration-execution-011CUpioCorDaL7Z7uuJL5y8' checked out at '/Users/saadkhan/Development/Victry GPT/victry'",
"timestamp": "2025-11-16T10:38:35.285Z"
},
{
"error": "Error: Language not supported while highlighting code, falling back to markdown",
"timestamp": "2025-11-16T10:38:35.451Z"
},
{
"error": "Error: Lock file is already being held",
"timestamp": "2025-11-16T10:38:42.836Z"
},
{
"error": "Error: Lock file is already being held",
"timestamp": "2025-11-16T10:38:59.015Z"
}
]
Note: Error logs were truncated at source.
</details>
Environment
- Platform: macOS (darwin)
- Terminal: Apple Terminal
- Claude Code Version: 2.0.42
- Date: 2025-11-16
- Time: ~10:38 UTC
Additional Context
- This is the first time encountering this issue
- This was the first extended/long-running session in Claude Code Web
- The two errors may be related (Web credit issue → problematic session state → CLI transfer error)
- No workarounds have been found
- Issue is currently ongoing
Possible Root Cause
The session transfer from Web to CLI may be carrying over corrupted state from the Web session, resulting in malformed tool result blocks. The initial "credit balance too low" error in Web might indicate a deeper session state issue rather than an actual billing problem.
Suggested Labels
bug, claude-code-web, session-transfer, high-priority, billing-display
Errors
[{"error":"Error\n at bw (/$bunfs/root/claude:59:1142)\n at <anonymous> (/$bunfs/root/claude:64:10074)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at spawnSync (unknown)\n at spawnSync (node:child_process:226:22)\n at lTT (/$bunfs/root/claude:94:1303)\n at uH (/$bunfs/root/claude:94:3608)\n at read (/$bunfs/root/claude:1628:4607)\n at request (/$bunfs/root/claude:66:2146)\n at processTicksAndRejections (native:7:39)\n at spawnSync (unknown)\n at spawnSync (node:child_process:226:22)\n at lTT (/$bunfs/root/claude:94:1303)\n at uH (/$bunfs/root/claude:94:3608)\n at read (/$bunfs/root/claude:1628:4607)\n at read (/$bunfs/root/claude:2147:17417)\n at tokens (/$bunfs/root/claude:2741:17132)\n at tokens (/$bunfs/root/claude:2741:18322)","timestamp":"2025-11-16T10:38:33.311Z"},{"error":"Error\n at bw (/$bunfs/root/claude:59:1142)\n at <anonymous> (/$bunfs/root/claude:64:10074)\n at emit (node:events:92:22)\n at endReadableNT (internal:streams/readable:861:50)\n at processTicksAndRejections (native:7:39)\n at request (/$bunfs/root/claude:66:2146)\n at processTicksAndRejections (native:7:39)","timestamp":"2025-11-16T10:38:33.351Z"},{"error":"Error: Failed to fetch from remote origin: fatal: refusing to fetch into branch 'refs/heads/claude/di-migration-execution-011CUpioCorDaL7Z7uuJL5y8' checked out at '/Users/saadkhan/Development/Victry GPT/victry'\n at _U_ (/$bunfs/root/claude:2210:356)\n at async pQT (/$bunfs/root/claude:2211:302)\n at async <anonymous> (/$bunfs/root/claude:4151:333)\n at async parseAsync (/$bunfs/root/claude:27:4180)\n at async su_ (/$bunfs/root/claude:4192:1646)\n at async au_ (/$bunfs/root/claude:4134:1739)\n at async eu_ (/$bunfs/root/claude:4192:13600)\n at processTicksAndRejections (native:7:39)","timestamp":"2025-11-16T10:38:35.285Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n at GX (/$bunfs/root/claude:1011:4471)\n at <anonymous> (/$bunfs/root/claude:1011:4193)\n at map (native:1:11)\n at YI (/$bunfs/root/claude:1011:4185)\n at ZqB (/$bunfs/root/claude:1629:3014)\n at D7 (/$bunfs/root/claude:102:19663)\n at I2 (/$bunfs/root/claude:104:42806)\n at $w (/$bunfs/root/claude:104:38344)\n at m1 (/$bunfs/root/claude:104:38272)\n at UJ (/$bunfs/root/claude:104:38126)","timestamp":"2025-11-16T10:38:35.451Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n at GX (/$bunfs/root/claude:1011:4471)\n at <anonymous> (/$bunfs/root/claude:1011:4193)\n at map (native:1:11)\n at YI (/$bunfs/root/claude:1011:4185)\n at ZqB (/$bunfs/root/claude:1629:3014)\n at D7 (/$bunfs/root/claude:102:19663)\n at I2 (/$bunfs/root/claude:104:42806)\n at $w (/$bunfs/root/claude:104:38344)\n at m1 (/$bunfs/root/claude:104:38272)\n at UJ (/$bunfs/root/claude:104:38126)","timestamp":"2025-11-16T10:38:35.454Z"},{"error":"Error: Lock file is already being held\n at <anonymous> (/$bunfs/root/claude:87:11857)\n at X (/$bunfs/root/claude:86:5167)\n at <anonymous> (node:fs:243:13)\n at processTicksAndRejections (native:7:39)","timestamp":"2025-11-16T10:38:42.836Z"},{"error":"Error: Lock file is already being held\n at <anonymous> (/$bunfs/root/claude:87:11857)\n at X (/$bunfs/root/claude:86:5167)\n at <anonymous> (node:fs:243:13)\n at processTicksAndRejections (native:7:39)","timestamp":"2025-11-16T10:38:59.015Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.2.content.0: unexpected `tool_use_id` found in `tool_result` blocks: toolu_01AeyvCRzKyC6aNziTmPiP3G. Each `too
Note: Error logs were truncated.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗