Repository navigation
Description
Summary
Messages sent from the mobile client in a DM channel carry no p tags, so agent harnesses never receive them as a turn. The event reaches the relay and shows up in history, but the agent stays silent. The same message sent from Desktop works, because Desktop implicitly p-tags every DM participant.
Root cause
Desktop has an explicit DM rule in desktop/src/features/messages/lib/messageMentionPubkeys.ts:
const candidates =
channel.channelType === "dm"
? [...explicitMentions, ...channel.memberPubkeys, ...channel.participantPubkeys]
: explicitMentions;Its doc comment names this exact requirement:
Stream messages notify only explicit mentions. A DM addresses every other participant, so it must carry recipient
ptags even when the composer text contains no@mention. Agent harnesses and human notification subscriptions both rely on those tags.
Covered by desktop/src/features/messages/lib/messageMentionPubkeys.test.mjs: "plain DM messages p-tag every recipient except the sender".
Mobile has no equivalent. mobile/lib/features/channels/send_message_provider.dart builds tags as:
final tags = <List<String>>[
['h', channelId],
if (parentEventId != null) ..._buildReplyTags(parentEventId, rootEventId),
for (final pk in normalizedMentions) ['p', pk],
...mediaTags,
];normalizedMentions comes only from explicitly passed pubkeys or from _resolveMentions(), which scans the text for @(\w+). There is no channelType == 'dm' branch anywhere in that file.
Reproduction
- Open a DM with a managed agent.
- Send a plain message from Desktop, e.g.
hello-> event has["h", <channel>]and["p", <agent pubkey>]; the agent replies. - Send the same plain message from mobile -> event has only
["h", <channel>](plus["e", ...]when replying in a thread); the agent never wakes.
Observed across 15 consecutive messages in one DM: all 9 events with a p tag produced an agent turn, all 6 without one were silently dropped. Correlation was exact; timing, message length and thread nesting made no difference.
Impact
From mobile, a user cannot talk to an agent in a DM at all unless they know to type a literal @AgentName. There is no error and no visual difference: the message appears delivered.
Suggested fix
Port the messageMentionPubkeys rule into send_message_provider.dart: when the channel is a DM, add the other participants to normalizedMentions before building the tags. Mirror the Desktop unit test on the mobile side.
Workaround
On mobile, type @AgentName in the message body so _resolveMentions() produces the p tag.
Activity