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.

  • Persistent (stream-json) agents have no PTY: the message is written as a {type:"user",…} line on the live stdin, which steers the agent mid-turn.
  • ACP agents receive the message as a session/prompt (the ACP controller’s send_input already wraps raw input that way).
  • 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).