buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(acp): keep top-level agent replies in channel [issue:#3825]

Open tcballard opened this issue 4 months ago • 2 comments

Summary

Implements #3825 and #3836, as part of the ordered workstream tracked by #3863.

Agent replies to top-level human mentions were being emitted as threaded replies, leaving the response out of the main channel timeline for users who were watching the channel or activity log. This change keeps the response visible at the channel root while preserving normal threaded conversation behavior.

Adds:

  • top-level human mention in a channel -> agent reply is sent without --reply-to, so it remains in the channel timeline;
  • human mention inside an existing thread -> agent reply anchors to that thread's root;
  • setup-mode nudges follow the same top-level/channel-root versus threaded/root behavior;
  • prompt guidance and ACP queue regression coverage for the routing contract.

Scope

Included

  • ACP prompt guidance for top-level channel responses.
  • ACP reply-anchor resolution for top-level and threaded human-facing turns.
  • Setup-mode nudge placement.
  • Regression coverage for top-level, threaded, batched, agent-only, and unknown-identity routing cases.

Excluded

  • No new Nostr event kind.
  • No new HTTP API or marketplace-specific protocol.
  • No desktop UI, layout, or command-palette changes.
  • DM reply behavior and agent-to-agent nesting semantics are unchanged.
  • No OEXL matching, payments, acceptance, ledger, settlement, or other marketplace code.

Product / Architecture Decisions

  • A top-level channel response is a channel-root message, so the ACP prompt explicitly instructs buzz messages send without --reply-to.
  • An already-threaded human-facing turn continues to reply to the thread root, keeping the conversation flat at the first reply level.
  • Agent-to-agent coordination remains free to use deeper nesting.
  • Setup-mode uses the same NIP-10 placement rule as normal ACP replies.
  • The existing Buzz message-send and NIP-10 thread path is reused; no parallel publishing mechanism is introduced.

User-Facing Contract

  • Mentioning an agent from a top-level channel message produces a visible top-level response in that channel.
  • Mentioning an agent from inside a thread produces a reply in that thread.
  • Setup-mode messages follow the same placement rules.

Verification

Ran

  • cargo fmt --all -- --check
  • cargo test -p buzz-acp queue::tests --lib (112 passed)
  • cargo test -p buzz-acp --lib (649 passed)
  • cargo clippy -p buzz-acp --all-targets -- -D warnings
  • git diff --check

Covered

  • Human top-level turns have no forced reply anchor.
  • Human threaded turns anchor to the thread root.
  • Batched events use the final event's scope without reusing an older thread.
  • Agent-only turns remain unanchored.
  • DM thread replies retain their existing reply behavior.
  • Setup-mode and ordinary ACP prompts use the same channel-root/thread-root distinction.

Review Path

Suggested review order: crates/buzz-acp/src/queue.rs reply-anchor and prompt changes, crates/buzz-acp/src/setup_mode.rs nudge placement, then the focused ACP tests.

Notes For Reviewer

This is a focused current-main contribution for #3825/#3836. It changes channel notice placement and ACP tests only; no desktop UI changed, so no screenshots are required. The earlier draft work on this area remains separate and is not stacked onto this branch.

tcballard avatar Jul 31 '26 11:07 tcballard

solid approach for #3825 — one ask: does the activity/pulse log still show the reply as threaded, or does that path also need the same top-level kind so mobile and desktop stay consistent?

chessing234 avatar Jul 31 '26 11:07 chessing234

@Chessing234 Addressed in 7b836377. Desktop and mobile activity/inbox coverage now asserts that a top-level kind:9 ACP reply with no NIP-10 e-tags remains a standalone activity row, while e-tagged replies continue to classify as threads. I also extended the channel-window E2E regression to assert that a kind:9 depth-1 broadcast reply carries the root's NIP-10 reply tag plus broadcast:1 and remains in the authoritative channel timeline. The focused desktop unit test, E2E test, Biome check, and Dart formatting pass; the local Flutter test runner stalled before producing output.

tcballard avatar Jul 31 '26 13:07 tcballard

Confirmed against Buzz 0.5.3 with a managed Hermes ACP agent: a top-level channel mention showed 👀/💬 and typing, and the agent log later recorded a completed turn with non-empty final output, but the user watching the mobile channel saw no inline response. Current ACP guidance forces --reply-to for top-level mentions, putting the final answer behind a thread instead of the channel timeline. This PR matches the reported visibility failure.

kerpopule avatar Aug 02 '26 05:08 kerpopule