[FEATURE] Allow providing tool_result via stdin when resuming session with pending tool_use
Open 💬 4 comments Opened Jan 7, 2026 by cheruvian
Description
When building wrappers around Claude Code CLI (mobile apps, custom UIs, etc.) that need to handle interactive tools like AskUserQuestion in non-interactive mode, there's no way to provide a tool_result via stdin without the CLI first injecting a synthetic response.
Current Behavior
When resuming a session that ends with a tool_use (e.g., AskUserQuestion) using --input-format stream-json:
- Session ends with:
[user] prompt→[assistant] tool_use - Resume with:
claude --resume <id> --input-format stream-json --output-format stream-json - CLI immediately injects:
[assistant] "No response requested." - Then reads stdin:
[user] tool_result - API rejects:
unexpected tool_use_id found in tool_result blocks
The chain is broken because the synthetic message is inserted between tool_use and tool_result.
Expected Behavior
When resuming with --input-format stream-json, the CLI should:
- Wait for stdin input before injecting any synthetic messages
- OR provide a flag like
--no-synthetic-responseto disable the injection - OR recognize that a
tool_resultmessage on stdin corresponds to the pendingtool_use
Use Case
Building a mobile/web wrapper for Claude Code that:
- Runs CLI in non-interactive mode (
-p,--output-format stream-json) - Detects
AskUserQuestiontool calls - Renders custom UI to collect user's answer
- Needs to provide the
tool_resultback to continue the session
Current Workaround
The only working approach is to:
- Write the
tool_resultdirectly to the session JSONL file (~/.claude/projects/.../<session>.jsonl) - Resume with a text prompt
This works but:
- Requires manipulating internal session files (fragile)
- Still results in an extra user turn and "No response requested" message
Reproduction
# 1. Start session, get AskUserQuestion, kill process
claude -p "Use AskUserQuestion to ask about my favorite color" \
--output-format stream-json --verbose \
--session-id test-123
# Kill when tool_use appears
# 2. Try to resume with tool_result via stdin
echo '{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"toolu_xxx","content":"Blue","is_error":false}]}}' | \
claude --resume test-123 \
--input-format stream-json \
--output-format stream-json --verbose
# Result: API error due to "No response requested" being injected first
Environment
- Platform: macOS
- Version: 2.0.76
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗