Skip to content

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

Open
Chessing234 wants to merge 1 commit into
block:mainfrom
Chessing234:fix/mobile-dm-recipient-p-tags
Open

fix(mobile): p-tag DM recipients so agents receive plain messages#3604
Chessing234 wants to merge 1 commit into
block:mainfrom
Chessing234:fix/mobile-dm-recipient-p-tags

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

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

  • 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

Desktop already tags every DM participant; mobile only added explicit
@mentions, so agent DMs from the phone never woke a turn.

Signed-off-by: Taksh <takshkothari09@gmail.com>
@ScaleLeanChris

Copy link
Copy Markdown

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.

@kerpopule

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

@Chessing234

Copy link
Copy Markdown
Contributor Author

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

@Chessing234
Chessing234 force-pushed the fix/mobile-dm-recipient-p-tags branch from 7bf6e48 to eae6a6e Compare August 5, 2026 10:36
@Japiewb

Japiewb commented Aug 6, 2026

Copy link
Copy Markdown

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

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.

Mobile: DM messages omit recipient p-tags, so agents never receive them

4 participants