buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(mobile): p-tag DM recipients so agents receive plain messages

Open chessing234 opened this issue 4 months ago • 5 comments

Summary

  • Port desktop's messageMentionPubkeys rule to mobile: DM sends now include p tags for every other participant/member, not only explicit @mentions
  • Without those tags, agent harnesses never receive a turn for plain DM text from the phone (Desktop already worked)

Test plan

  • [x] flutter test test/features/channels/message_mention_pubkeys_test.dart test/features/channels/send_message_provider_test.dart
  • [ ] Open a DM with a managed agent on mobile, send hello with no @mention — event carries ["p", <agent>] and the agent replies
  • [ ] Same plain message in a stream channel — still no invented recipient p tags
  • [ ] Explicit @Agent mentions in a DM still work and stay deduped with the auto recipients

Fixes #3591

Made with Cursor

chessing234 avatar Jul 29 '26 19:07 chessing234

Independent validation from a real Buzz mobile client, hosted Buzz relay, and the Fly Hermes identity:

  • A plain mobile DM, “hey fly,” arrived as kind:9 with only the DM h tag. It had no recipient p tag.
  • An explicit “@Fly yo” message added Fly's p tag.
  • Two later plain DM messages again arrived without a p tag.

That reproduces #3591 at the event boundary and confirms the failure is in mobile message construction, not relay delivery. This PR's helper matches the desktop rule: plain DMs address every other participant, explicit mentions remain deduplicated, self is excluded, and stream messages do not invent recipient tags.

I mirrored the exact contributor commit into fork CI because the upstream workflow has not been approved yet. The mobile job passed, including file-size checks, format, analysis, Flutter tests, and an Android debug APK build. The overall fork workflow also ran unrelated desktop jobs; its macOS desktop build failed before compiling Buzz because the mesh-llm checkout was unavailable.

One limitation: our Fly agent uses Hermes's native Buzz adapter, which already works around missing DM p tags by classifying the channel as a DM. Fly therefore still replied after its conversation was latched. This proves the malformed mobile event and the code correction, but it does not independently reproduce the managed ACP wake failure.

After this fix, a plain mobile DM can say “Hello” without also spelling out @Fly.

ScaleLeanChris avatar Jul 30 '26 06:07 ScaleLeanChris

Confirmed against Buzz 0.5.3 mobile plus a managed Hermes ACP agent configured with subscribe=Mentions. A plain mobile DM produced no agent acknowledgement or turn, while an explicit channel @mention produced the expected 👀/💬 acknowledgement and typing state. Current mobile send code only emits p tags for explicit mentions, so the harness cannot classify/address the plain DM. This PR fixes the observed failure at the sender boundary.

kerpopule avatar Aug 02 '26 05:08 kerpopule

Follow-up live canary: after channel replies became visible, a new mobile DM still produced no ACP prompt at all. At 2026-08-02 00:08 CDT the Hermes managed-agent log remained unchanged since its last prompt at 23:25:34 CDT. This rules out slow model execution and hidden reply placement for the DM case; the event is being dropped before harness dispatch, consistent with the missing mobile DM recipient p tag fixed here.

kerpopule avatar Aug 02 '26 05:08 kerpopule

@tlongwell-block @wesbillman @wpfleger96 mind taking a look when you get a chance?

chessing234 avatar Aug 02 '26 08:08 chessing234

Independent confirmation of both the bug and the approach, from a production Buzz DM (hosted relay, Buzz Desktop + the iOS app, managed Claude Code ACP agent):

Raw events pulled from the same DM channel via buzz messages get:

  • Sent from mobile: "tags":[["h","<channel-uuid>"]] — no recipient p tag; the managed agent was never woken and only saw the message once a later event triggered it.
  • Same DM from desktop: "tags":[["h","<channel-uuid>"],["p","<agent-pubkey>"]] — agent triggered immediately.
  • Mobile with an explicit @mention: p tag present, agent triggered — matching the workaround others reported here.

Before finding this PR we independently implemented the same rule in SendMessage (auto-p-tag DM participants with a member-list fallback, merged through the existing normalization so dedupe and self-exclusion still apply; stream/forum channels unchanged) and converged on the same behavior this PR describes — effectively N=2 on the approach. On today's main the full mobile suite passes with that change (1246 tests, flutter analyze clean, dart format clean).

Since this PR currently shows merge conflicts: a conflict-free equivalent based on today's main, with three added send_message_provider tests (DM auto-tag, non-DM no implicit tags, member-list fallback), is at Japiewb:fix/mobile-dm-recipient-p-tags in case it helps with the rebase — happy for any part of it to be folded in here. Not opening a second PR, to keep review in one place.

🤖 Generated with Claude Code

Japiewb avatar Aug 06 '26 13:08 Japiewb

closing — main already has mobile dm recipient p-tags via messageMentionPubkeys

chessing234 avatar Sep 01 '26 15:09 chessing234