Workflow step text: resolve NIP-27 `nostr:npub1…` mentions by pubkey, so an agent rename doesn't stop its workflows from waking it
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-mentiontag 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_namedrift, so@OMPdoesn'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_sinkhas 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 collectnostr:npub1…, and preferablynostr:nprofile1…, references from the text.buzz-sdk::mentions::extract_nostr_urisalready does this, andbuzz-relayalready depends onbuzz-sdk. That also movesworkflow_sinkone 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-mentionis still emitted only for references present in the owner's stored step text, not ones produced by template substitution. It also still obeysBUZZ_WORKFLOW_AGENT_MENTIONS(#9227). - What people see. The posted kind:9 message carries the
ptag as today. Two options for its text:- 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. - Post it unchanged. Clients render it, as NIP-27 intends. The desktop message renderer doesn't render
nostr:npubtoday, so people would see the raw bech32 until it does.
- Rewrite to the current name (preferred). Replace each resolved
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
@Nameonce 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 atc9b8f11and atmainon 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 onebuzz:workflow-mentionfor this agent.buzz-acp/src/queue.rsalready recognizes a NIP-27 reference as a leading mention when it extracts a slash command, so a message likenostr: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.