Skip to content

The agent that grows with you

fix(bot-mode): a local group member is never re-driven on its own reply

teknium117ad4d7465b1
diff --git a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
index d5ab300f6aa..1cba3780144 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
@@ -12,7 +12,7 @@ import {
} from './group-chat'
import type { GroupChatRoom } from './group-chat'
import { groupMemberAuthor, groupMemberKey } from './group-membership'
-import { buildGroupChatTurnPrompt, formatGroupDeltaLines } from './group-round-prompt'
+import { buildGroupChatTurnPrompt, formatGroupDeltaLines, isGroupChatSelf } from './group-round-prompt'
import { isGroupPassText, runGroupChatMemberTurn } from './group-turns'
import type { Attachment, GroupMember, GroupMessage } from './types'
@@ -302,10 +302,7 @@ export async function runGroupRoundMember(
}
function authoredByMember(entry: GroupMessage, member: GroupMember): boolean {
- const from = entry?.from
- const source = member.remoteSource ? member.connectionLabel || member.connectionId : undefined
-
- return from?.kind === 'member' && from.name === member.name && String(from.source || '') === String(source || '')
+ return entry?.from?.kind === 'member' && isGroupChatSelf(entry.from, member)
}
export async function runGroupContinuationMembers(
diff --git a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts
index fbf40db6c3d..b20fdf1f504 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts
@@ -112,7 +112,9 @@ function viewerConnectionSources(viewer: GroupChatLineViewer): string[] {
return [viewer.connectionLabel, viewer.connectionId].filter((token): token is string => Boolean(token))
}
-function isGroupChatSelf(from: GroupMessageAuthor, viewer: GroupChatLineViewer): boolean {
+/** Whether `from` is the viewer itself — the one authorship rule for the
+ * `(you)` suffix and for the round's own-entry watermark walk. */
+export function isGroupChatSelf(from: GroupMessageAuthor, viewer: GroupChatLineViewer): boolean {
if (!from.name || from.name !== viewerNameOf(viewer)) {
return false
}
diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
index b32fa360e00..4542b050ff5 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
@@ -271,6 +271,20 @@ describe('routing', () => {
).not.toContain('(you)')
})
+ // The watermark walk and the (you) check must agree on who wrote a line: a
+ // local member's sourced reply read as somebody else's came back to it as
+ // room news, and it answered itself until the round cap.
+ it('never re-drives a local member on its own sourced reply', async () => {
+ const room = await loadRoom({ turn: ({ n }) => `Reply ${n} from this device.` })
+ const local: GroupMember = { connectionId: 'local', connectionLabel: 'This device', name: 'default', title: '' }
+
+ room.rounds.sendToGroupChat('Core', [local], '@hermes status?')
+ await settle(room, 'Core')
+
+ expect(room.gateway.calls).toHaveLength(1)
+ expect(log(room, 'Core').map(entry => entry.text)).toEqual(['@hermes status?', 'Reply 1 from this device.'])
+ })
+
// Two Desktops label the same gateway differently ("Central" here, "Studio"
// there): the reply's gateway install_id, not the label, decides `(you)`.
it('matches self on the gateway install_id when Desktops label the connection differently', async () => {