claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Mid-execution input fails with streaming mode error when using --model haiku

Open arthurwolf opened this issue 1 month ago • 1 comments

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?

When sending input to a Claude Code instance mid-execution (while the initial prompt is still being processed), the instance crashes with exit code 1 and reports the error: "only prompt commands are supported in streaming mode". This occurs specifically when the Claude instance is spawned with the --model haiku flag (BUT out of nearly 50 tests, I've seen it happen once with --model opus, so this might not be a completely set rule. I've never seen the error not happen with --model haiku though)

The issue manifests as an error_during_execution event in the streaming JSON output containing the error message "only prompt commands are supported in streaming mode", followed by instance termination with exit code 1.

What Should Happen?

Claude should accept mid-execution input without errors, allowing the user to send follow-up prompts while the initial prompt is still being processed (such as during long-running tool execution).

Error Messages/Logs

{
    "type": "result",
    "subtype": "error_during_execution",
    "duration_ms": 0,
    "duration_api_ms": 0,
    "is_error": true,
    "num_turns": 0,
    "session_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "total_cost_usd": 0,
    "usage": {
      "input_tokens": 0,
      "cache_creation_input_tokens": 0,
      "cache_read_input_tokens": 0,
      "output_tokens": 0
    },
    "errors": [
      "only prompt commands are supported in streaming mode"
    ]
  }

  Instance stopped with:
  {
    "event": "stopped",
    "reason": "crashed",
    "exit_code": 1
  }

Steps to Reproduce

Prerequisites:

  • Claude Code CLI (latest version)
  • Ability to send JSON to stdin in stream-json format
  • Any command that takes >60 seconds to execute (e.g., sleep 120)

Steps:

  1. Spawn Claude with --model haiku and these flags: claude
    --output-format stream-json
    --input-format stream-json
    --verbose
    -p
    --include-partial-messages
    --dangerously-skip-permissions
    --session-id <UUID>
    --add-dir /home/user
    --model haiku
  2. Send initial prompt via stdin: {"type":"user","message":{"role":"user","content":"Answer 2+2, then sleep 120 seconds."}}
  3. Wait 60 seconds
  4. Send second prompt via stdin: {"type":"user","message":{"role":"user","content":"3+3="}}
  5. Observe result: Instance crashes with "only prompt commands are supported in streaming mode" error

Minimal Example Script: #!/bin/bash SESSION_ID=$(uuidgen) claude
--output-format stream-json
--input-format stream-json
--verbose -p
--include-partial-messages
--dangerously-skip-permissions
--add-dir /home/user
--model haiku
--session-id "$SESSION_ID" << 'EOF' & {"type":"user","message":{"role":"user","content":"Sleep 120 seconds"}} EOF

CLAUDE_PID=$! sleep 60 echo '{"type":"user","message":{"role":"user","content":"What is 3+3?"}}' >&0 wait $CLAUDE_PID

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.4

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

Root Cause Analysis:

Through systematic testing (bisecting command-line arguments one-by-one), the error was isolated to the --model haiku flag specifically.

Test Results:

  • Baseline (no model): ✓ PASS
  • With -p: ✓ PASS
  • With --include-partial-messages: ✓ PASS
  • With --dangerously-skip-permissions: ✓ PASS
  • With --add-dir: ✓ PASS
  • With --model haiku: ✗ FAIL - Streaming Mode Error

The same command line with --model sonnet or --model opus works without errors.

Impact:

This affects any system using Claude Code with mid-execution input (live prompt capability) when haiku model is specified. The WebSocket-based agent service in particular would be affected when spawning instances with haiku model.

Related Files/Code:

If applicable, this may relate to Claude Code's handling of the streaming mode when models are explicitly specified, particularly how it manages stdin input during execution.

Reproducibility:

  • Consistently reproducible with haiku model
  • Does not occur with sonnet or opus models
  • Does not occur without model specification

arthurwolf avatar Jan 11 '26 00:01 arthurwolf

Claude code did some of the debugging for this, here is its full report: https://gist.github.com/arthurwolf/152a3c46a5a8955adc1fd672ad013992

arthurwolf avatar Jan 11 '26 01:01 arthurwolf

Im seeing this error too even with --input-format set to text

DarrenBaldwin07 avatar Jan 31 '26 15:01 DarrenBaldwin07