Skip to content

fix(acp): exempt DM channels from the mention gate; seed mobile presence cache - #6307

Open
tpotu wants to merge 2 commits into
block:mainfrom
tpotu:fix/acp-dm-mention-exemption
Open

tpotu wants to merge 2 commits into
block:mainfrom
tpotu:fix/acp-dm-mention-exemption

Conversation

@tpotu

@tpotu tpotu commented Aug 19, 2026

Copy link
Copy Markdown

Problem

Agents running buzz-acp in mentions mode require a p tag on every message — including in DM channels, at two layers: the relay REQ subscription includes #p, and filter::match_event re-checks the mention locally. The desktop composer auto-adds the agent p tag in agent DMs, but the mobile composer only tags explicit @name mentions. Result: a plain DM sent from mobile never reaches the agent (the relay never delivers it), the agent stays silent, and users conclude the agent is offline.

Separately, the mobile presence cache had no initial fetch (track() was a no-op) — every user and agent read as offline until their next live kind:20001 event arrived, up to 60s for agents publishing heartbeats and indefinitely for users who published before the client connected.

Diagnosed on a live deployment: the same agent answered desktop DMs (p-tagged) within seconds while an untagged mobile DM sat unanswered for two days.

Fix

buzz-acp — DM channels (channel_type == "dm") are exempt from the mention gate; a DM addresses the agent implicitly:

  • resolve_channel_filters takes the set of DM channel ids and drops require_mention for them (mentions mode only; All/Config modes unchanged)
  • resolve_dynamic_channel_filter takes is_dm; the membership-notification path looks the type up via discover_channels(), fail-closed to mention-required on lookup errors
  • filter::match_event takes mention_exempt and skips the p-tag check for DM channels
  • setup mode passes the real DM set at startup, an empty set on the dynamic path (no relay probe from setup mode)

mobilePresenceCacheNotifier.track() now issues a one-shot POST /query (kinds [20001], authors = newly tracked pubkeys); the relay synthesizes presence from its store as relay-signed events with the subject in the p tag, and the handler supports both that shape and live self-signed events. Tracked pubkeys are re-fetched on (re)connect.

Testing

  • cargo test -p buzz-acp --lib: 819 passed after merging current main (3 new: DM exemption in static resolution, dynamic resolution, and match_event)
  • cargo clippy -p buzz-acp --all-targets: clean
  • flutter test (mobile): 1525 passed (2 new: bridge-seeded fetch incl. filter shape, no refetch of already-tracked pubkeys)
  • flutter analyze: no issues
  • E2E on a live relay: DM without any p tag → agent responds within one turn; group channels still require @mention

🤖 Generated with Claude Code

Tom Potutschek and others added 2 commits August 19, 2026 11:06
…nce cache

Agents running in mentions mode required a `p` tag even in DM channels —
both in the relay REQ filter (#p) and the local rule check. Desktop
auto-tags agent DMs, but mobile only tags explicit @name mentions, so
plain DMs sent from mobile were silently dropped and agents appeared
unresponsive. A DM addresses the agent implicitly: channels of type
"dm" now skip the mention requirement (mentions mode only; startup
discovery and dynamically added channels alike, fail-closed on type
lookup errors).

Also seed the mobile presence cache with a one-shot POST /query fetch
per newly tracked pubkey (and on reconnect). Without it, everyone read
as offline until their next live kind:20001 event — up to 60s for
agents, or never for users who published before the client connected.
Synthesized presence events are relay-signed with the subject in the
`p` tag; the handler supports both shapes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tpotu
tpotu requested a review from a team as a code owner August 19, 2026 12:41
@Giszmo

Giszmo commented Aug 23, 2026

Copy link
Copy Markdown

#4201 is the more concise and consistent fix for this, isn't it?

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.

2 participants