feat(relay): notify channel when an offline agent is @mentioned#2296
feat(relay): notify channel when an offline agent is @mentioned#2296Bartok9 wants to merge 1 commit into
Conversation
When a channel message @mentions an agent (bot member) that has no active WebSocket subscription, the relay fan-out silently delivers nothing to it and the mention is lost with no signal to the sender, channel, or any human observer (issue block#1743 — a real 30-minute silent stall between two agents). After a kind:9 (KIND_STREAM_MESSAGE) message is dispatched, this checks any `p`-tagged pubkeys that are bot members against presence. For each mentioned bot with no presence key, it emits a relay-signed system notice (agent_mention_undelivered) into the channel: "<agent> is offline and may not see this mention." Human recipients and online agents are never flagged. - Best-effort, spawned side-effect: never adds latency to dispatch and never fails the triggering event; presence/DB errors are logged and skipped. - Reuses the existing emit_system_message helper (kind:40099). - Pure gating logic extracted to select_offline_mentioned_bots with unit tests. Refs block#1743 Signed-off-by: Bartok9 <danielrpike9@gmail.com>
9daf893 to
359dce5
Compare
|
Blocking evidence against current head Wire-format evidenceCurrent Desktop reply construction always begins with a structural author tag: const tags: string[][] = [
["p", authorPubkey],
["h", channelId],
];See This PR's ingest hook collects every
PR #1862 received this exact review finding and moved toward explicit Required correctionUse an unambiguous explicit-mention signal rather than treating all
Please also document the guarantee accurately: presence is a useful reachability warning, not a delivery receipt proving that a particular harness subscription admitted the event. Separate end-to-end response timing evidence is tracked in #2386; this comment is about notification correctness. |
|
Thanks — this is a fair and precise catch. You're right that intersecting all I'll rework this to key off an unambiguous explicit-mention signal rather than the raw
And I'll fix the docs to frame presence as a reachability warning, not a delivery receipt. E2E timing stays scoped to #2386. Will push the revision. |
Refs #1743
Problem
When agent A @mentions agent B and B is offline (no active WebSocket subscription), the relay fan-out (
dispatch_persistent_event_inner) delivers nothing to B and the mention is silently lost — no signal to the sender, the channel, or any human. As reported in #1743 (filed by agent Ferret, co-authored with Timpani), this caused a real 30-minute silent stall when Timpani delegated to an offline Fizz. Any agent-to-agent workflow that delegates via @mention is fragile when the target may be offline.Why it matters
Agents are first-class citizens in Buzz. Silent mention loss breaks agent-to-agent delegation with no fallback at the agent layer (the send call returns success regardless of whether anyone is subscribed). At minimum, the mention must not vanish without a trace.
What this changes (Option 1 from the issue — relay system notice)
After a
kind:9(KIND_STREAM_MESSAGE) message is dispatched, the relay:p-tagged pubkeys on the message.get_presence_bulk.{ "type": "agent_mention_undelivered", "agent_pubkey": "<hex>", "agent_name": "<name>", "message": "<name> is offline and may not see this mention." }This is client-agnostic (works for desktop, mobile, third-party NIP-29 clients) because it lives at the relay.
Design / safety
emit_system_message(kind:40099) — no new event-kind machinery.select_offline_mentioned_botsfor unit testing without DB/redis.buzz_agent_mention_undelivered_totalmetric for observability.How to test
Unit tests cover: only offline bot members are selected (online agents and non-bot humans excluded), and empty result when all mentioned are online or non-bots.
Manual: start two agents in a channel, stop one, @mention it → a system notice appears in the channel naming the offline agent.
Signed-off-by DCO.