Skip to main content

deliver_agent_message

Function deliver_agent_message 

Source
pub fn deliver_agent_message(
    block_id: &str,
    message: &str,
) -> Result<AgentDelivery, String>
Expand description

Deliver an inter-agent / muxbus message to a running agent the way its controller expects.

Callers of this function are automated senders by definition — muxbus, the reactive/jekt handler, MCP SendMessage, the messaging bridges. The message reaches the agent at once, whatever it is doing: the agent gets it as soon as it can act on it (docs/specs/SPEC_JEKT_IMMEDIATE_DELIVERY_2026_09_28.md §2.1). The human operator’s own input does not come through here — it goes via the agentinput RPC.

  • Persistent (stream-json) agents have no PTY: the message is written as a {type:"user",…} line on the live stdin, mid-turn included. It is queued only while the process is starting up, restarting or stopping.
  • ACP agents receive the message as a session/prompt (the ACP controller’s send_input already wraps raw input that way).
  • App Server (Codex) agents have no PTY either: the message is queued/dispatched as a turn/start request via app_server_controller::AppServerController::send_message.
  • Everything else (shell/term PTY agents, one-shot subprocess agents) is reported as AgentDelivery::Pty so the caller uses keystroke injection — preserving today’s behavior.

This is the controller-aware delivery primitive muxbus Tier-1 needs: PTY keystrokes silently fail to reach a persistent stream-json agent (it rejects raw input). Spec: docs/specs/SPEC_AGENT_CONTROL_PROTOCOL_2026_06_15.md §6 (Phase 3).