400 error: empty text content block when background tasks complete during user input
Resolved 💬 6 comments Opened Feb 3, 2026 by davidrimshnick Closed Mar 6, 2026
Bug Description
Claude Code crashes with a 400 API error when multiple background tasks complete at the same time a user message is submitted. The API rejects the request because an empty/whitespace-only text content block was included in the messages payload.
Error
API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must contain non-whitespace text"},"request_id":"req_011CXmr4oRpidzbNEWgayqKE"}
Steps to Reproduce
- Start multiple long-running background commands (e.g., calibration scripts taking several minutes each)
- Wait for them to complete around the same time
- Submit a user message while the background task completion notifications are being processed
In my case, three background tasks completed in quick succession right before/during my message:
Background command "Run opponent calibration..." completed (exit code 0)
Background command "Re-run calibration..." completed (exit code 0)
Background command "Compare MCTSLite 200 vs random" completed (exit code 0)
⎿ Interrupted · What should Claude do instead?
❯ [user message typed here]
⎿ API Error: 400 ...
Expected Behavior
The message should be sent successfully. Empty text content blocks should be filtered out or not generated when assembling the API request.
Actual Behavior
The session crashes with a 400 error and cannot be recovered.
Environment
- Claude Code v2.1.30
- Model: Opus 4.5
- OS: Windows (Git Bash / MINGW64)
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗