buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(desktop): buzz agents draft-create succeeds on relay but fails to trigger Desktop draft review form

Open Markus-it-support opened this issue 4 months ago β€’ 4 comments

Summary

When executing buzz agents draft-create from an external VPS CLI, the relay accepts the NIP-IA draft event ("accepted": true, kind 9035), but the Buzz Desktop app on macOS fails to receive/render the prefilled draft form for owner review.

Codebase References

Per desktop/src-tauri/src/managed_agents/nest_skill.md and crates/buzz-acp/src/base_prompt.md:

"Agent draft commands add {request_id, action, saved: false} because they only open an owner-reviewed Desktop draft. Buzz Desktop resolves local runtime/provider/model defaults..."

Environment Details

  • CLI Host: Ubuntu Linux (Remote VPS)
  • Desktop Host: macOS (Buzz Desktop)
  • Relay: Managed Relay Server (https://markus-biz.communities.buzz.xyz)

Steps to Reproduce

  1. Execute draft-create from a remote VPS with valid BUZZ_PRIVATE_KEY and BUZZ_AUTH_TAG:
    BUZZ_PRIVATE_KEY="<nsec...>" \
    BUZZ_AUTH_TAG='["auth","..."]' \
    ./target/release/buzz agents draft-create \
      --channel "<channel_uuid>" \
      --display-name "Athena AI" \
      --system-prompt "System prompt..."
    
    

Observe successful relay response: {"accepted":true,"action":"create","event_id":"8b4b261e...","saved":false}

Open or refresh Buzz Desktop on macOS.

Check Inbox, channel view, and Agents tab.

Expected Behavior Buzz Desktop should consume the incoming kind 9035 event on its WebSocket connection, apply local defaults, and open a reactive draft approval modal/banner for the workspace owner.

Actual Behavior No draft review pop-up, banner, or form opens in Buzz Desktop.

The agent appears in the channel member list (Athena AI πŸ”’ managed by you), but does not populate inside the main Agents tab gallery.

No headless CLI command (e.g. buzz agents approve) exists to save/approve the draft directly from the server side.

Related Work Related to open PR #3610 (fix(desktop): queue agent draft requests).

Markus-it-support avatar Jul 30 '26 19:07 Markus-it-support

Traced this at origin/main (4d47aa83). The relay is behaving correctly β€” the problem is that draft-create has no delivery guarantee at all, so this sequence can't work today regardless of what Desktop does.

The frame is kind 24200, not 9035. buzz agents draft-create builds a KIND_AGENT_OBSERVER_FRAME (crates/buzz-core/src/kind.rs:409) β€” the CLI asserts this directly in crates/buzz-cli/src/agent_management.rs:210 (assert_eq!(built.event.kind.as_u16(), 24_200)). Kind 9035 is the NIP-IA archive request, a different feature. Worth correcting since it changes where to look.

24200 is ephemeral, and ephemeral means never stored. It sits in the 20000–29999 range that kind.rs:396 documents as "Never stored." Two independent places enforce that:

  • crates/buzz-relay/src/handlers/event.rs:680 routes 24200 into handle_agent_observer_event (line 943). That function verifies the signature, applies a Β±5 minute freshness window, checks owner authorization, publishes to pubsub, calls fan_out_event_to_local_subscribers (line 1089), and replies RelayMessage::ok(event_id_hex, true, "") at line 1091. There is no database write anywhere on that path.
  • Independently, crates/buzz-db/src/event.rs:268 rejects every ephemeral kind from storage outright (DbError::EphemeralEventRejected).

So {"accepted":true} does not mean "Desktop received it." It means the relay verified the frame and fanned it out to whichever subscribers were connected at that instant. If none were, the frame is simply gone β€” no persistence, no retry, no delivery receipt. The CLI prints "Draft sent to Buzz Desktop for owner review" unconditionally (crates/buzz-cli/src/commands/agents.rs), which is why this reads as a Desktop bug rather than a dropped message.

That explains the reported sequence exactly: run draft-create on a remote VPS, then open or refresh Buzz Desktop. The frame was fanned out and discarded before Desktop ever connected. Refreshing can't recover it, the Agents tab can't show it, and as noted there's no buzz agents approve to fall back on. Today the CLI and Desktop must be connected simultaneously for a draft to land β€” that requirement isn't documented anywhere I could find.

On the related PR: #3610 is a real fix for a real bug, but a different one. It addresses desktop/src/features/agents/useAgentManagement.ts, where seenRequestIds.current.add(next.requestId) runs before the pendingRequestId.current === null check β€” so a second draft arriving while one is already open is marked seen and discarded permanently. That's the concurrent-draft drop from #3559. It requires a frame to have been delivered in the first place, so it won't change this report.

(One more note in case it saves someone time: the app-level RequestedAgentCreateDialogs.tsx / openCreateAgentEvent.ts pair looks like the relevant code but isn't on this path. requestOpenCreateAgent has three callers, all in-app buttons β€” app/AppShell.tsx:862, features/channels/ui/ChannelMembersBar.tsx:223, and features/channels/useWelcomeAgentCreate.ts:48. Nothing relay-side dispatches that event; CLI-originated drafts arrive via observerRelayStore.ts β†’ subscribeAgentManagementRequests β†’ useAgentManagement.ts.)

A durable fix needs persistence. Options as we see them, roughly in increasing order of cost:

  1. Make the CLI honest. fan_out_event_to_local_subscribers (handlers/event.rs:241) already computes its recipient list but returns (). Returning the count and surfacing it for control-direction frames would let draft-create warn "no subscriber was connected β€” this draft was not delivered" instead of reporting plain success. This doesn't fix delivery, but it converts a silent loss into an actionable message. Caveat: on a multi-node relay a Desktop attached to a different node still receives the frame via pubsub, so a zero local count isn't proof of non-delivery β€” the signal would have to be advisory.
  2. Persist draft requests so they survive Desktop being closed β€” either a stored kind for the management-request subset or a bounded relay-side retention buffer that replays pending drafts on subscribe. This is the only option that makes the reporter's VPS workflow work, and it's a protocol change, so it wants maintainer direction before anyone writes code.
  3. A headless approve path (buzz agents approve), which several remote workflows would want anyway, though it's orthogonal to the loss itself.

Happy to implement whichever direction maintainers prefer β€” we have (1) mostly scoped already. Mainly wanted the corrected kind and the no-persistence finding on the record first, since the current framing points at Desktop rendering rather than at delivery.

jbforge avatar Jul 30 '26 21:07 jbforge

Root cause from reproducing this today on a self-hosted relay: the desktop's draft trust gate rejects drafts whose sender is not already in the desktop's local managed-agent store.

desktop/src/features/agents/agentManagementBuffer.ts β€” classifyAgentManagementOrigin returns accept only when (a) the sending agent's pubkey is in the desktop's own ManagedAgent list AND (b) owner + sender share the claimed origin channel. Everything else is reject, silently β€” the relay has already answered accepted:true ("Draft sent to Buzz Desktop for owner review"), so the sender has no way to learn the draft was dropped.

Repro: provision an agent server-side (own identity, systemd-launched, never created through the desktop), have it run buzz agents draft-create --channel <shared channel> ... β†’ relay accepts, desktop shows nothing, no log the user ever sees. The same command from a desktop-managed agent opens the review form fine.

The trust gate itself seems right (arbitrary identities shouldn't be able to pop forms in the owner's desktop) β€” the bug is the silent half. Either the relay should validate sender-is-desktop-managed at submission (so the CLI gets a real error), or the desktop should surface rejected drafts somewhere visible (a dismissible "draft from unrecognized agent X was ignored" row). Happy to PR whichever direction maintainers prefer.

jdrolls avatar Aug 02 '26 15:08 jdrolls

Additional reproduction (Outdoor Boost community relay)

Reproduced on Buzz Desktop 0.5.9 (xyz.block.buzz.app) against wss://outdoorboostai.communities.buzz.xyz with Desktop running the whole time.

What we confirmed locally

  • buzz agents draft-create returns {accepted:true, saved:false, event_id, request_id} (CLI + Desktop are the same desktop-v0.5.9 build tree).
  • Delivery is an encrypted observer payload (ObserverEvent<CreateAgentDraft>), wire type agent_management_request β€” not kind 9035 (9035 is NIP-IA archive). Matches the correction already on this issue.
  • Senders were Desktop-managed agents (e.g. Fizz 89372145…, Grok 4d323a5d…) that are channel members β€” so this is not only the unrecognized-sender trust-gate case from the earlier comment.
  • buzz social event --event <id> returns [] (expected for ephemeral observer frames).
  • Related: open PR #3610 (queue while a draft is already open) and the ephemeral fan-out / no-persistence analysis already on this thread.

Source vs installed binary note

desktop/src/features/agents/agentManagement.ts (and useAgentManagement.ts / classifyAgentManagementOrigin) exist on tag desktop-v0.5.9. Independently, a plaintext scan of the installed buzz-desktop Mach-O did not find the wire string agent_management_request (nor parseAgentManagementRequest / subscribeAgentManagementRequests). That may be bundling/minification, or a packaging gap worth a maintainer glance β€” calling it out because our first binary-only pass incorrectly concluded β€œreceiver not shipped.”

One probe that did land

A diagnostic draft-create with display name Grok Draft Probe later appeared as a saved managed agent (managed-agents.json mtime / created_at β‰ˆ 2026-08-11T23:30:21Z) with the exact probe system prompt. So delivery is not 0% β€” but many accepted calls still produce no visible review UI.

Happy to provide event_id/request_id pairs from the outdoorboostai relay session if useful.

citizenscolumn avatar Aug 11 '26 23:08 citizenscolumn

Buzz Desktop desktop-v0.5.23 (latest desktop tag in the repo; installed 2026-09-05), buzz CLI buzz.exe dated 2026-09-05 (no version string; buzz --version is not a valid argument) Relay: a Buzz-hosted community relay (*.communities.buzz.xyz), not self-hosted OS: Windows 11 Pro 10.0.26200, Hyper-V VM; agents run via buzz-acp with the Claude runtime

Cannot reproduce on desktop-v0.5.23 (Windows 11, Hyper-V VM) - the draft now reaches Desktop:

2026-09-21 06:24:18 UTC: buzz agents draft-create --channel --display-name b003-probe-verwerfen --system-prompt "..." returns accepted:true, action:create, saved:false, request_id c34404d0-d868-49a0-9ecc-c6d7b4c76188, CLI message "Draft sent to Buzz Desktop for owner review" (event 082d03d51639f424481b5b5b3b70e19d1361f9891c735b57f70e462b454c1a75, ephemeral kind 24200). 2026-09-21 06:24:38 UTC (20 s later): Desktop created the agent - agents/logs/79bddb39...log starts with === starting b003-probe-verwerfen (79bddb39...) at 2026-09-21T06:24:38 ===, managed-agents.json has the full record (acp_command buzz-acp, agent_command claude-agent-acp, turn_timeout 320), pid file present. Owner confirmed (2026-09-21 08:43 local): the draft form opened in Desktop and was saved by clicking Save. Earlier failure on our side (2026-08-27: accepted on relay, nothing in Desktop) was on the previous host installation; string grep on 0.5.23 binaries (agent_management_request 0x in buzz-desktop.exe) is therefore not a valid indicator. Still open for us, probably #7304: an agent imported from a snapshot card (.agent.png, tEXt chunk buzz_agent_snapshot) lands in setup mode with runtime/provider/allowlist/timeout unset and needs a manual draft-update (2026-09-15 and 2026-09-20). draft-update for an existing agent works (2026-09-16/17, six drafts 5-10 s apart; sent back-to-back only one arrives).

Buzz Desktop desktop-v0.5.23 (latest desktop tag in the repo; installed 2026-09-05), buzz CLI buzz.exe dated 2026-09-05 (no version string; buzz --version is not a valid argument) Relay: a Buzz-hosted community relay (*.communities.buzz.xyz), not self-hosted OS: Windows 11 Pro 10.0.26200, Hyper-V VM; agents run via buzz-acp with the Claude runtime

Addendum, same setup (desktop-v0.5.23, Windows 11, Hyper-V VM): draft-create does reach Desktop on 0.5.23, but not reliably. Four buzz agents draft-create today, all answered accepted:true by the CLI/relay:

06:24:18 UTC: form opened in Desktop, saved, agent created 06:24:38 UTC. 07:21 UTC: form opened, saved, agent created 07:21:29 UTC. 08:10:05 UTC (request 2b92dbfc): nothing. No form in Desktop, managed-agents.json untouched for the next 8 minutes, buzz-desktop.exe running the whole time (same pid since the day before), owner looked at Desktop at 08:18 UTC: nothing open. 08:18:50 UTC (request d50ad41c, identical content, same sender): form opened within seconds, saved, agent created 08:18:57 UTC. So 1 of 4 drafts was silently dropped between relay accept and the Desktop form; the sender cannot tell (kind 24200 is ephemeral, there is no receipt). A confirmation event from Desktop, or a visible "draft received" entry, would make this diagnosable.

salvatoremira1969-rgb avatar Sep 21 '26 06:09 salvatoremira1969-rgb