[FEATURE] Deterministic external inbox injection semantics (Phase 1)
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
Claude Code has multiple open feature requests for programmatic/session-targeted messaging, but there is not yet a single deterministic runtime contract for how injected messages behave when a session is busy.
For orchestration and multi-agent workflows, "message injection exists" is not sufficient. We also need stable, machine-verifiable delivery semantics under load.
Current gaps (from user perspective):
- No deterministic distinction between best-effort immediate delivery and strict immediate delivery.
- No standard receipt contract for accepted/queued/downgraded/rejected outcomes.
- No idempotent retry behavior for external orchestrators.
This blocks reliable external inbox adapters and forces fragile workarounds (human relay, tmux/send-keys, one-shot subprocesses).
Proposed Solution
Add a single Phase 1 runtime feature: deterministic external inbox injection semantics for running sessions.
Scope for Phase 1:
- Add a session-targeted injection entrypoint (CLI/API surface is maintainers' choice).
- Support these delivery inputs:
after_turnnowimmediate
- Define deterministic busy-state behavior:
after_turn: always queuenow: try immediate; if busy and strict=false, downgrade toafter_turnimmediate: strict immediate; if busy, reject withbusy
- Return machine-readable delivery receipts on every request.
- Support idempotent retries with caller-supplied idempotency key.
Suggested request/response shape (illustrative):
{
"session_id": "...",
"text": "...",
"delivery": "now|immediate|after_turn",
"idempotency_key": "...",
"source": "external_inbox",
"importance": "normal"
}
{
"accepted": true,
"queued": true,
"downgraded": true,
"delivery_requested": "now",
"delivery_effective": "after_turn",
"reason": "downgraded_busy",
"idempotency_status": "new"
}
Acceptance criteria:
- Busy +
immediate=> rejected withreason=busy. - Busy +
now(non-strict) => accepted, queued, downgraded toafter_turn. - Idle +
now=> accepted and delivered as immediate. - Any state +
after_turn=> queued deterministically. - Duplicate idempotency key => deterministic duplicate response (
skipped_duplicateor equivalent). - Receipts always include requested mode, effective mode, and reason.
Non-goals for Phase 1:
- No true in-stream turn interruption bridge yet.
- No cross-session mesh/event subscription protocol yet.
Alternative Solutions
Workarounds tried:
- Human relay between sessions
- tmux/send-keys style terminal automation
- one-shot
-psubprocess orchestration
These are non-deterministic or lose session continuity.
Related issues (conceptual progression):
- #24947 -
claude injectcommand concept - #15553 - programmatic submission in interactive mode
- #20921 - event subscriptions for real-time communication
- #26000 - external approval delegate pattern
- #27441 - inter-agent message injection request
This proposal fuses those ideas into one bounded, testable Phase 1 runtime contract.
Priority
High - Significant impact on productivity
Feature Category
CLI commands and flags
Use Case Example
Example scenario:
- A long-running Claude Code session is actively generating.
- External orchestrator receives a high-priority update.
- Orchestrator sends
delivery=nowwith idempotency key. - Runtime responds deterministically:
- if busy and non-strict: queued+downgraded receipt
- if idle: immediate delivery receipt
- Orchestrator updates its state machine from the receipt without guessing.
Additional Context
High-level blast radius (Phase 1):
- Injection ingress surface (CLI/API parser + validation)
- Session routing and ownership/auth checks
- Runtime busy-state decision path and queue insertion
- Idempotency store/check
- Receipt serialization + telemetry/event logging
- Documentation + integration tests for the acceptance criteria above
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗