[FEATURE] Support an interrupt message on stdin
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
I've built an overlay tool that runs on top of Claude CLI using --input-format stream-json in headless mode. It orchestrates multiple concurrent agents, and users need to be able to redirect agents mid-task — the same way you'd press ESC in the interactive CLI to stop the current tool and type a new instruction.
Proposed Solution
Support an interrupt message on stdin:
{"type": "interrupt"}
When received:
- Abort the currently executing tool (same behavior as ESC)
- Keep the process and session alive
- Process the next queued {"type": "user", ...} message immediately
Usage pattern:
→ {"type": "interrupt"}
→ {"type": "user", "message": {"role": "user", "content": "Stop that and focus on X instead"}}
Alternative Solutions
Alternatives Considered
┌──────────────┬───────────────────────────────────┐
│ Approach │ Issue │
├──────────────┼───────────────────────────────────┤
│ Agent SDK interrupt() │ Requires API billing — can't use Claude subscription │
├──────────────┼───────────────────────────────────┤
│ SIGINT / CTRL_BREAK │ Kills the process entirely in headless mode │
├──────────────┼───────────────────────────────────┤
│ Kill + respawn -r │ Slow, fragile, loses in-flight tool state │
├──────────────┼───────────────────────────────────┤
│ Write to stdin while running │ Queued until turn ends — not a real interrupt │
└──────────────┴───────────────────────────────────┘
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗