[BUG] Spurious error_during_execution after background task in stream-json mode causes CLI to exit

Resolved 💬 5 comments Opened Jan 8, 2026 by soundsys Closed Jan 14, 2026

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?

Two result messages are emitted in sequence:

  1. Success result (correct):

{"type":"result","subtype":"success","is_error":false,"duration_ms":8127,...}

  1. Spurious error result (incorrect):

{"type":"result","subtype":"error_during_execution","duration_ms":0,"duration_api_ms":0,"is_error":true,"num_turns":0,...,"errors":["only prompt commands are supported in streaming mode"]}

After emitting the error, the CLI exits instead of remaining alive to accept more input.

What Should Happen?

  1. Only the success result should be emitted - no spurious error
  2. The CLI should stay running and continue accepting input via stdin (interactive stream-json mode)

Error Messages/Logs

{"type":"result","subtype":"success","is_error":false,"duration_ms":6794,"duration_api_ms":20704,"num_turns":2,"result":"Started a background bash task that echoes \"test\". The task is running with ID `bec84fd`. You can check its output at `/tmp/claude/-Users-soundsys/tasks/bec84fd.output` or I can retrieve the results for you when you're ready.","session_id":"de527d48-3b46-481e-827d-08e9f2ce215c","total_cost_usd":0.15837574999999998,"usage":{"input_tokens":2,"cache_creation_input_tokens":4864,"cache_read_input_tokens":30280,"output_tokens":159,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":4864}},"modelUsage":{"claude-haiku-4-5-20251001":{"inputTokens":312,"outputTokens":171,"cacheReadInputTokens":0,"cacheCreationInputTokens":10779,"webSearchRequests":0,"costUSD":0.01464075,"contextWindow":200000},"claude-opus-4-5-20251101":{"inputTokens":3759,"outputTokens":452,"cacheReadInputTokens":30280,"cacheCreationInputTokens":15760,"webSearchRequests":0,"costUSD":0.14373499999999997,"contextWindow":200000}},"permission_denials":[],"uuid":"84dc5ca1-8a84-4122-aef5-28a125fa0d90"}
{"type":"result","subtype":"error_during_execution","duration_ms":0,"duration_api_ms":0,"is_error":true,"num_turns":0,"session_id":"de527d48-3b46-481e-827d-08e9f2ce215c","total_cost_usd":0,"usage":{"input_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":0,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0}},"modelUsage":{},"permission_denials":[],"uuid":"50f31e31-2c53-46b6-8a4b-7bbc7232fb7e","errors":["only prompt commands are supported in streaming mode"]}

Steps to Reproduce

echo '{"type":"user","message":{"role":"user","content":"start a background bash task: echo test"}}' | claude --print --output-format stream-json --input-format stream-json --verbose

Claude Model

Other

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.76

Claude Code Version

2.1.1

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗