buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Workflow step text: resolve NIP-27 `nostr:npub1…` mentions by pubkey, so an agent rename doesn't stop its workflows from waking it

Open samsymbia opened this issue 2 weeks ago • 0 comments

Motivation

A workflow wakes an agent only through a @<display name> written in the owner's saved step text. resolve_mention_pubkeys (crates/buzz-relay/src/workflow_sink.rs) matches that name against the channel members' current display names on every run. The result is the buzz:workflow-mention tag that buzz-acp requires (verified_workflow_owner).

So the link between a saved workflow and the agent it addresses is a name, re-resolved at run time:

  • Renaming the agent silently breaks every workflow that addresses it. The workflow keeps running and posting, and people still see the message, so nothing looks wrong. But the old name no longer resolves, no buzz:workflow-mention tag is emitted, and the agent never wakes. There is no error at save time (the name was valid then), and none at run time.
  • Two members with the same display name in a channel wake no one (by design, to avoid misrouting). So an unrelated person joining with a colliding name can also disable a working workflow.
  • The workflow owner can't fix it in advance. The only stable identity Buzz has, the pubkey, isn't accepted in step text.

We hit this designing agents that write and own workflows on a user's behalf ("every Monday at 9, post the open proposals in #team"). The agent's display name is something the customer is expected to change. Interactive mentions survive that, because clients resolve a selection into a p tag at compose time. Workflow text is stored as free text and re-parsed on every run, so it doesn't.

Closest existing issues:

  • #5371: the agent's configured name and its profile display_name drift, so @OMP doesn't resolve. Same root cause, a different trigger: that issue proposes resolving more name aliases, and this one proposes an ID that doesn't depend on names at all.
  • #2686: workflow_sink has its own, divergent mention parser.

Proposed solution

Accept NIP-27 references in send_message step text, and resolve them by pubkey:

  • Parsing. In resolve_mention_pubkeys, also collect nostr:npub1…, and preferably nostr:nprofile1…, references from the text. buzz-sdk::mentions::extract_nostr_uris already does this, and buzz-relay already depends on buzz-sdk. That also moves workflow_sink one step toward the shared parser #2686 asks for.
  • Membership check. A reference counts only if the pubkey is a current member of the destination channel, the same membership rule names already follow. No name lookup, so renames and duplicate display names don't matter.
  • Authority rule unchanged. buzz:workflow-mention is still emitted only for references present in the owner's stored step text, not ones produced by template substitution. It also still obeys BUZZ_WORKFLOW_AGENT_MENTIONS (#9227).
  • What people see. The posted kind:9 message carries the p tag as today. Two options for its text:
    1. Rewrite to the current name (preferred). Replace each resolved nostr:npub1… with @<current display name>. People see a normal mention with today's name, the routing tags come from the pubkey, and no client change is needed. A reference that doesn't resolve to a channel member is left as is.
    2. Post it unchanged. Clients render it, as NIP-27 intends. The desktop message renderer doesn't render nostr:npub today, so people would see the raw bech32 until it does.

Saving a definition could also warn when a @Name in step text doesn't resolve right now. That's orthogonal, but it makes the name-based failure visible.

Alternatives considered

  • Resolve aliases (agent name, profile name, display name) — #5371's direction. This helps with the configured-name vs profile-name gap, but not with renames: a renamed agent's old name is still gone.
  • Freeze the pubkey at save time. The relay resolves @Name once when the definition is saved, and stores the pubkey alongside the text. This survives renames with no new syntax. But it changes what a stored definition means, needs a schema change, and a later edit of the YAML would re-resolve against whatever names exist then.
  • Have the owner rewrite workflows on every rename. That's what we'll do downstream for now. It's only possible because the owner is the agent itself and our rename path holds its key. It doesn't help a person who owns a workflow addressing an agent that someone else renamed.

Additional context

  • crates/buzz-relay/src/workflow_sink.rs: resolve_mention_pubkeys, append_workflow_mention_tags (checked at c9b8f11 and at main on 2026-11-12, after #9227).
  • crates/buzz-sdk/src/mentions.rs: extract_nostr_uris.
  • crates/buzz-acp/src/lib.rs: verified_workflow_owner, the requirement for exactly one buzz:workflow-mention for this agent.
  • buzz-acp/src/queue.rs already recognizes a NIP-27 reference as a leading mention when it extracts a slash command, so a message like nostr:npub1… /review <url> already works there.

Duplicates searched: "workflow mention", "npub mention workflow". The closest are #5371 and #2686 (linked above). None found that propose a pubkey-based reference.

Happy to send a PR for this. The parser change is small, and the tests can reuse extract_nostr_uris's.

Written by Claude Code.

samsymbia avatar Nov 13 '26 06:11 samsymbia