buzz icon indicating copy to clipboard operation
buzz copied to clipboard

buzz-acp: non-steerable ACP agents (oh-my-pi/omp) silently drop mid-turn messages (ExpectedRunIdMissing deadlock)

Open arcimun opened this issue 4 months ago • 3 comments

Non-steerable ACP agents (e.g. oh-my-pi/omp) silently drop mid-turn messages

Environment

  • repo: block/buzz @ ac4fa13, buzz-acp 0.5.3
  • agent: omp acp (oh-my-pi 17.2.3, an ACP server that does not advertise steering)
  • relay: hosted community, subscribe=Mentions, meh=Steer, parallelism=10, max_turn_duration=7200

Symptom The agent connects fine (owner resolved, channel subscribed, presence online). But every user message is logged and dropped:

steer: no active_run_id and agent did not advertise _session/steering — falling back to cancel+merge
non-cancelling steer ack received … ack=Ok(Err(ExpectedRunIdMissing)) signal_fallback=true

No session/prompt ever fires; the user sees a "typing" indicator but never receives a reply. Reproduced on every message across multiple sessions.

Root cause (from source)

  1. lib.rs relay-event gate (if accepted && queue.is_channel_in_flight(…)) routes an event to a steer signal when the channel is marked in-flush.
  2. omp advertises neither _meta.steering.supported nor goose activeRunId, so try_native_steer returns false → falls back to signal_in_flight_task (ControlSignal::Steer).
  3. acp.rs steer arm acks SteerError::ExpectedRunIdMissing; the main loop maps that to the cancel+merge fallback.
  4. pool.rs:1954 if agent.acp.has_in_flight_prompt() is false for omp → the "already completed" branch runs, and for Steer apply_completed_before_control_signal does nothing — the message is stranded.
  5. The queue stays in_flight (deadline = max_turn_duration, kept alive by extend_in_flight_deadline) → flush_next excludes the channel → the queued event is never re-dispatched.

Steerable agents (claude-agent-acp, goose) don't hit this because their turn exposes a cancel/merge target.

Proposed fix direction When a mode-gate Steer/cancel is required for a channel whose agent has no active in-flight prompt (non-steerable / stale in_flight), do not fire a steer signal into a void — release the channel (queue.mark_complete(channel_id)) and let dispatch_pending re-prompt the queued event as a fresh session/prompt. A check of the channel's prompt-task agent state (or completion-time reconciliation) distinguishes "genuinely in-flight" from "stale".

Acceptance With a non-steerable ACP agent: sending a DM should produce a real session/prompt and the reply should be published. Steerable agents must remain unchanged.

arcimun avatar Aug 01 '26 22:08 arcimun

Confirmed independently on macOS with two Kimi K3 agents using Kimi Code CLI 0.29.2. Each runtime initialized with steering_supported=false. Under the default meh=Steer, I captured the same sequence:

steer: no active_run_id and agent did not advertise _session/steering
ack=Ok(Err(ExpectedRunIdMissing)) release_withheld=true

The UI showed the agent as working, but no real prompt ran, no artifact was produced, and no reply arrived. Restarting the runtime did not recover the stranded request.

Setting BUZZ_ACP_MULTIPLE_EVENT_HANDLING=queue on both agents and restarting them restored delivery; both startup lines now show dedup=Queue meh=Queue. This is a useful mitigation, but not a complete fix because queue mode can batch independent events and lose one-event/one-reply identity, as described in #3176.

Suggested acceptance coverage: when an adapter advertises steering_supported=false, or returns ExpectedRunIdMissing while no prompt is actually in flight, release any stale channel lease and dispatch the withheld event as a fresh prompt. Also test relay disconnect/reconnect: the same event should eventually run exactly once after reconnection, without an accepted side effect being repeated.

HashMac avatar Aug 03 '26 12:08 HashMac

+1 to @HashMac's confirmation and the queue mitigation above — adding a third runtime/OS data point plus a few details their report didn't cover: a harsher failure mode (agent process killed and respawned, not just a stranded request), and the Desktop per-agent route to the workaround.

Setup: Buzz Desktop on Windows 11, managed agent running hermes-acp (hermes-agent 0.20.0 / 2026.8.3), which advertises loadSession and sessionCapabilities.{fork,list,resume} but not _session/steering.

Signature (identical mechanism to the OP, different agent):

WARN buzz_acp::acp: steer: no active_run_id and agent did not advertise _session/steering — falling back to cancel+merge
INFO buzz_acp: non-cancelling steer ack received ... ack=Ok(Err(ExpectedRunIdMissing)) release_withheld=true drop_withheld=false signal_fallback=true
INFO acp_adapter.server: Cancelled session ...
WARN buzz_acp::acp: hard turn timeout exceeded (silence 5.0053036s)
WARN buzz_acp: agent_returned — respawning (cancel-drain timeout) outcome="cancel_drain_timeout" grace=5s

In our case the effect was worse than a dropped message: because the agent was mid-tool-call when the cancel landed, it could not drain within the 5s grace, so the whole agent process was killed and replaced — taking the unsent reply with it. Every quick follow-up message in the channel restarted the cycle, so a non-steerable agent under active conversation never got a reply out.

Workaround until the proposed re-dispatch fix lands: set multiple-event-handling to queue for the affected agent. In Buzz Desktop this can be done per-agent via the agent's env_vars:

BUZZ_ACP_MULTIPLE_EVENT_HANDLING=queue

(CLI equivalent: --multiple-event-handling queue.) With queue, mid-turn mentions wait for the current turn instead of triggering the cancel+merge path, and the cancel_drain_timeout respawn loop disappears entirely. We've been running a hermes agent this way in an active multi-agent channel since; steerable agents (claude-agent-acp) are unaffected either way, consistent with the OP.

One asymmetry worth noting for whoever picks this up: Desktop appears to pass some settings as explicit CLI args (which win over env) — --mcp-command for instance — but multiple-event-handling does honor the per-agent env var, which is what makes this workaround viable from the UI.

mattlutzz avatar Aug 10 '26 19:08 mattlutzz

Two additions from a reproduction with a different adapter.

1. claude-code-acp is also non-steerable. The report says steerable agents don't hit this and names claude-agent-acp. @zed-industries/claude-code-acp 0.16.2 — a different package — reports no steering capability, so it takes exactly the same path:

INFO  agent initialized … name="@zed-industries/claude-code-acp" steering_supported=false
INFO  non-cancelling steer not accepted — falling back to cancel+merge
WARN  steer: no active_run_id and agent did not advertise _session/steering — falling back to cancel+merge

buzz-acp also sends session/set_config_option {configId:"mode", value:"dontAsk"} to this adapter and gets -32601 "Method not found" back, while the harness startup line still prints permission_mode=dontAsk — so the configured mode is silently not in effect. Mentioning it only because it made the steer behaviour harder to attribute.

2. On a seat with --subscribe all, the fallback is not just dropped messages — it exhausts the container. Same mechanism, different consequence. One short work cycle (~8 human messages in one channel):

steer: … falling back to cancel+merge          × 94
hard turn timeout exceeded
agent_returned … outcome="cancel_drain_timeout" grace=5s
respawn complete

cgroup v2 measurements at the end of that cycle, three seats on the same relay, same image, same isolation flags:

seat subscribe memory.current anon zombie procs
conductor all 4,779 MiB 4,538 MiB 88
A mentions 35 MiB 33 MiB 0
B mentions 218 MiB 213 MiB 0

anon rules out page cache — docker stats alone conflates the two. The zombies are the respawned agent children; buzz-acp is pid 1 in the container and does not reap them.

A fourth seat with --lazy-pool --idle-pool-sleep 60 went from a 216 MiB active peak down to 3 MiB after idle pool sleep bound reached — tearing pool back to lazy state, so the pool teardown path does reclaim — it just never gets the chance while the cancel/respawn loop keeps the turn alive.

Note for anyone benchmarking this: it is invisible to an idle test. The same two seats sat in a channel for 31 minutes with no human message and produced zero events and zero growth. It only appears once traffic starts.

Possible direction. Deciding on the capability flag alone would be wrong — acp.rs picks the transport as (Some(run_id), _) => Goose, (None, true) => AcpExtension, (None, false) => None, so an agent with an activeRunId steers fine even with the flag false. Latching the effective mode to queue per agent on the first observed SteerError::ExpectedRunIdMissing would leave those agents untouched while stopping the loop for agents that can never accept a steer.

Workaround for anyone hitting this now: --multiple-event-handling=queue.

Gforce10-design avatar Aug 28 '26 10:08 Gforce10-design