fix(acp): deliver plain-text replies when the model skips the send tool
What
Adds a content-delivery fallback to buzz-acp: when a managed agent answers a
conversational prompt in plain assistant text and never calls the publish tool
(buzz messages send), the harness posts that streamed content as a threaded
kind-9 reply — instead of silently dropping it.
Capable hosted models reliably publish via the send tool, but weaker local / shared-compute models (e.g. a small Gemma/Qwen) often just answer in prose and never call the tool, so the reply is lost. This closes that gap.
How
Delivery is confirmed from the send tool call's terminal outcome, not its input text — intent is not delivery:
- A
tool_callwhose input matches the publish signature (normalized so both shell strings and argv forms likesubprocess.run(['buzz','messages','send',…])match) only registers a candidatetoolCallId. - The candidate is resolved on its terminal
tool_call_update:failed/cancelled→ not delivered (fallback stays armed).completed→ inspectrawOutput.isError, the CLI's{"accepted":…}response envelope, and any reportedexit_code. A barecompletedwith no inspectable output keeps the status-quo direction (suppress).
- On a normal
EndTurnwith buffered content but no confirmed publish, post the content as a threaded reply (buzz_sdk::build_message, signed with the agent keys, best-effort — mirrorspost_failure_notice). Bare acknowledgements the base prompt forbids publishing are skipped.
Fires only on EndTurn (not MaxTokens/MaxTurnRequests, which are
truncated/aborted turns) and only when a triggering channel event was present
(not heartbeats).
Testing
- Unit: send-tool detection incl. read-vs-send discrimination and argv-style publishes; the outcome classifier matrix (pending/failed/cancelled/completed × envelope/isError/exit_code); bare-ack filtering.
- Handler-level lifecycle tests through
handle_session_update+take_undelivered_turn_message: success, failure, cancel, failed-then-retry, and argv-style publish. - Original fallback was live-validated against a small Gemma on a real community: fires on prose answers, stays dormant when the model calls the send tool.
Notes
Split out of #2448 so this reply-delivery fix stands on its own, independent of
that PR's shared-compute usability changes. +710 / crates/buzz-acp only — no
desktop / mesh / toggle changes.