Skip to content

fix(relay): stop workflow code spans from waking the agents they document - #7686

Open
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/workflow-mention-code-masking-7660
Open

BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:fix/workflow-mention-code-masking-7660

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

A workflow that renders an agent's name inside a code block or inline code span still woke that agent. Workflow text is machine-generated markdown, and agents emit code constantly — a code sample naming a colleague is documentation, not an address.

What happens

resolve_mention_pubkeys in crates/buzz-relay/src/workflow_sink.rs scanned the raw workflow text for @name matches, with no awareness of code regions. A mention inside an inline code span or fenced block therefore produced a real p tag on the emitted kind 9 message, and those p tags gate ACP agent wake (event_mentions_agent), so the agent was pinged for something it was only mentioned in as example code.

The CLI compose path already strips code regions before extracting @name mentions (crates/buzz-cli/src/commands/messages.rs, via buzz_sdk::mentions::strip_code_regions). The relay workflow sink never got the equivalent.

The change

Mask code regions with the existing buzz_sdk::mentions::strip_code_regions before scanning, on both the rendered output and the owner's authored template. The helper is already public in the SDK and buzz-relay already depends on buzz-sdk, so this adds no new dependency and no second masking implementation to keep in step.

One invariant worth calling out: strip_code_regions is not length-preserving, so nothing downstream may map positions from the masked copy back onto the original text. resolve_mention_pubkeys is safe today because only pubkeys (in first-appearance order) escape the function, and the code comment now pins that invariant for future refactors.

Tests

Four new cases in the workflow_sink test module:

  • see ping @robby for syntax — inline code span mention wakes no one
  • fenced block containing ping @Robby — wakes no one
  • `code` then @Robby please — masking must not swallow surrounding prose; the prose mention still wakes
  • a mid-line fence (not at a line start) is currently left intact by strip_code_regions; that behavior is pinned so a future SDK change that masks it is a visible decision

Verification

cargo test -p buzz-relay on this branch: all 25 workflow_sink tests pass (21 prior, 4 new). The full package suite runs 1144 tests with 6 pre-existing api::media failures that require a live Postgres pool (Sqlx(PoolTimedOut)); verified identical on pristine main at 213092074 with the fix stashed, so they are unrelated to this change. cargo clippy -p buzz-relay --all-targets and cargo fmt -- --check are clean.

Fixes #7660

…ment

resolve_mention_pubkeys in workflow_sink.rs scanned raw workflow text for
@name mentions, so a mention inside an inline code span or fenced block
became a real p tag and gated ACP agent wake. Workflow text is
machine-rendered markdown and agents emit code constantly - a name inside
a code region is documentation, not an address.

The CLI compose path already masks code regions before mention extraction
(buzz-cli messages.rs); this gives the relay workflow sink the same
treatment by running buzz_sdk::mentions::strip_code_regions over the
text before scanning, reusing the shared SDK helper instead of a
relay-local mask.

strip_code_regions is not length-preserving, so the scan operates on the
masked copy; positions never map back to the original string (only
pubkeys, in first-appearance order, escape) and the comment in
resolve_mention_pubkeys pins that invariant for future refactors.

Fixes block#7660

Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
@BradGroux
BradGroux requested a review from a team as a code owner September 16, 2026 18:58
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 213092074c269bee90c87163672f9c2b8d714cfe...11b0e67a2f8de05850d2d9b31bee80df9560b2e9.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 11b0e67a2f8de05850d2d9b31bee80df9560b2e9 to authorize a new review.
Any previous review applies only to its recorded range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workflow_sink's mention parser never masks code regions — @name inside a code span wakes the agent

1 participant