claude -p returns empty result despite valid response when rate limit overageStatus is rejected
Bug
claude -p returns empty result despite model generating valid response when rate limit overageStatus: "rejected".
Reproduction
claude -p "Say hello" --output-format stream-json --verbose
Stream-JSON output (sanitized)
{"type":"system","subtype":"init","cwd":"/home/user/myproject","session_id":"REDACTED","tools":["Bash","Edit","Glob","Grep","Read","Write"],"mcp_servers":[],"model":"claude-opus-4-6[1m]","permissionMode":"default","apiKeySource":"none","claude_code_version":"2.1.83","fast_mode_state":"off"}
{"type":"assistant","message":{"model":"claude-opus-4-6","id":"REDACTED","type":"message","role":"assistant","content":[{"type":"text","text":"\n\nHello."}],"stop_reason":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":2783,"cache_read_input_tokens":14707,"output_tokens":2,"service_tier":"standard"}}}
{"type":"rate_limit_event","rate_limit_info":{"status":"allowed","resetsAt":1774447200,"rateLimitType":"five_hour","overageStatus":"rejected","overageDisabledReason":"org_level_disabled","isUsingOverage":false}}
{"type":"result","subtype":"success","is_error":false,"duration_ms":4086,"num_turns":1,"result":"","stop_reason":"end_turn","total_cost_usd":0.024,"usage":{"input_tokens":3,"output_tokens":6}}
Line 2: Model responds with "text":"\n\nHello." — valid response.
Line 3: Rate limit event fires with overageStatus: "rejected".
Line 4: result is "" — the response is silently dropped. Exit code is 0, stderr is empty.
Expected behavior
If the model generates a response and it's returned in the assistant message, result should contain that text. If rate limiting should block the response, the call should fail BEFORE generating tokens — not after charging for them ($0.024 for an empty result).
Actual behavior
--output-format textreturns just\n--output-format jsonreturns"result":""- Exit code is 0, stderr is empty
- User is charged for generated tokens that are discarded
Workaround
Use --output-format stream-json --verbose and parse the assistant message events directly instead of relying on the result field.
Impact
Any automation using claude -p (CI, scripts, agents) silently fails. No error signal — rc=0, no stderr. The only indication is an empty stdout, which is indistinguishable from the model choosing to return nothing.
Environment
- Claude Code: 2.1.83
- Platform: Linux (WSL2)
- Model: claude-opus-4-6[1m]
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗