The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): nudge an explicitly addressed member that (pass)ed
liuhao10248567d8a24318
diff --git a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts b/apps/desktop/src/plugins/hermes-bots/group-round-members.tsindex 1cba3780144..3a2804cb9c0 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,12 @@ import {} from './group-chat'import type { GroupChatRoom } from './group-chat'import { groupMemberAuthor, groupMemberKey } from './group-membership'-import { buildGroupChatTurnPrompt, formatGroupDeltaLines, isGroupChatSelf } from './group-round-prompt'+import {+ buildGroupChatTurnPrompt,+ formatGroupDeltaLines,+ GROUP_ADDRESSED_NUDGE_SUFFIX,+ isGroupChatSelf+} from './group-round-prompt'import { isGroupPassText, runGroupChatMemberTurn } from './group-turns'import type { Attachment, GroupMember, GroupMessage } from './types'@@ -24,6 +29,12 @@ export interface GroupRoundMemberContext {binding: { isLive(): boolean }isCurrent(): booleanfailedMembers?: Set<string>+ /** #129443: member keys the driving user send explicitly addressed+ * (@everyone / @mention). An addressed member's "(pass)" gets one bounded+ * nudge; a second "(pass)" is recorded as explicit noncompliance — never+ * ordinary silence. Absent/empty = collaborative turn, where a plain+ * "(pass)" stays legitimate. */+ addressedKeys?: null | Set<string>}/** #93129: a held member's skip must consume its delta exactly once —@@ -177,6 +188,26 @@ export async function runGroupRoundMember(try {reply = await runVisibleMemberTurn(context, member, prompt, deltaImages)++ // #129443: the participation rules ("reply only with something new,+ // else (pass)") let a directly addressed member pass just because a+ // teammate already answered — the room then settles as ordinary+ // consensus and the user's explicit address silently disappears. One+ // bounded nudge re-asks with the directive spelled out; the recovered+ // reply replaces the pass and flows through the exact same commit path+ // below. A nudge that throws falls into the catch like any failed turn.+ // `isCurrent()` (not the bare binding): a superseded drive's pass is+ // discarded by the epoch check right below anyway, so nudging it would+ // burn a model call whose result can never be committed.+ if (context.isCurrent() && reply !== null && isGroupPassText(reply) && context.addressedKeys?.has(memberKey)) {+ reply = await runVisibleMemberTurn(+ context,+ member,+ `${prompt}${GROUP_ADDRESSED_NUDGE_SUFFIX}`,+ deltaImages+ )+ }+accepted = true// Needs-attention hook (#93091 item 3): a turn that produced a real@@ -278,6 +309,23 @@ export async function runGroupRoundMember(if (reply !== null && spoke) {appendGroupChatEntry(context.group, groupMemberAuthor(member), reply, thread)+ } else if (reply !== null && context.isCurrent() && context.addressedKeys?.has(memberKey)) {+ // #129443: the nudge was passed on too. Record the noncompliance where+ // the user looks (activity row + roster badge) instead of letting the+ // user's explicit address settle as ordinary quiet consensus. Only a+ // CURRENT drive's pass is disclosed: a turn the epoch check just+ // tolerated committing (a cross-thread send superseded its drive) is+ // stale residue, and flagging it would point the user at an address+ // their newer send already moved past.+ const reason = 'explicitly addressed member passed twice'++ recordGroupActivity(context.group, {+ kind: 'failed',+ member: groupMemberKey(member),+ reason,+ thread+ })+ noteBotAttention(groupMemberKey(member), reason)}// A member's own entries — its reply, and the rows group-external-writes.tsdiff --git a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.tsindex b20fdf1f504..08dfbbb4abf 100644--- a/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-round-prompt.ts@@ -177,3 +177,16 @@ export function buildGroupChatTurnPrompt({ groupName, members, viewer, deltaLine'- Never reveal content from your private 1:1 chats. Your reply text goes to the room verbatim — no preamble, no meta-commentary.'].join('\n')}++/** #129443: appended once when a member the user EXPLICITLY addressed+ * (@mention / @everyone) answered the room's "(pass)". The participation+ * rules above let a member pass whenever it has nothing new to add, and a+ * member whose teammate already answered usually has nothing new — so the+ * redundancy heuristic, not the addressing, ends up deciding. The re-ask+ * spells the directive out; the engine, not the wording, owns the+ * invariant (a second "(pass)" is recorded as noncompliance). */+export const GROUP_ADDRESSED_NUDGE_SUFFIX = [+ '',+ 'You just replied "(pass)", but the user explicitly addressed YOU in this turn (@you or @everyone).',+ 'A direct address cannot be passed on. Reply now with ONE message: your answer, your result, or an explicit statement that you cannot answer and why.'+].join('\n')diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.addressed.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.addressed.test.tsnew file mode 100644index 00000000000..165fd306060--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.addressed.test.ts@@ -0,0 +1,164 @@+/**+ * #129443 — the redundancy "(pass)" must not swallow an explicit address.+ *+ * The room's participation rules tell a member to reply only with something+ * new and otherwise "(pass)" — so in an @everyone turn the second member+ * passes whenever the first already answered, and a directly addressed+ * member's silence settles as ordinary consensus. The engine, not the prompt+ * wording, owns the invariant: `explicitlyAddressedMemberKeys` carries the+ * user's addresses as structured state, an addressed member's "(pass)" gets+ * ONE bounded nudge, and a second "(pass)" is recorded as an explicit+ * noncompliance (activity row + roster badge) instead of quiet silence.+ * Ordinary unaddressed collaborative "(pass)" is untouched.+ */++import { beforeEach, describe, expect, it, vi } from 'vitest'++import type * as groupActivity from './group-activity'+import type * as groupChat from './group-chat'+import type * as groupMembership from './group-membership'+import type * as groupRounds from './group-rounds'+import { createGroupGateway, drain, runTimersInline, scriptedStorage } from './group-test-utils'+import type { GatewayOptions, ScriptedGateway } from './group-test-utils'+import type { GroupMember, GroupMessage } from './types'++const { host } = vi.hoisted(() => ({ host: {} as Record<string, unknown> }))++vi.mock('@hermes/plugin-sdk', async () => {+ const { pluginSdkMock } = await import('./group-test-utils')++ return pluginSdkMock(host)+})++interface Room {+ activity: typeof groupActivity+ chat: typeof groupChat+ gateway: ScriptedGateway+ membership: typeof groupMembership+ rounds: typeof groupRounds+}++async function loadRoom(options: GatewayOptions = {}): Promise<Room> {+ vi.resetModules()+ const gateway = createGroupGateway(options)++ for (const key of Object.keys(host)) {+ delete host[key]+ }++ Object.assign(host, gateway.host)++ const [activity, chat, membership, rounds, shared] = await Promise.all([+ import('./group-activity'),+ import('./group-chat'),+ import('./group-membership'),+ import('./group-rounds'),+ import('./shared')+ ])++ shared.setPluginCtx(scriptedStorage(gateway.storage))++ return { activity, chat, gateway, rounds, membership }+}++const MEMBERS: GroupMember[] = [+ { name: 'research', title: '' },+ { name: 'builder', title: '' }+]++const log = (room: Room, group: string) => room.chat.$groupChats.get()[group]?.log || []++/** Run the room's drive to completion. */+async function settle(room: Room, group: string) {+ await drain(() => Boolean(room.chat.$groupChats.get()[group]?.running))+}++beforeEach(() => {+ runTimersInline()+})++describe('explicitlyAddressedMemberKeys', () => {+ const user = (text: string): GroupMessage[] =>+ [{ at: 1, from: { kind: 'user', name: 'You' }, text }] as GroupMessage[]++ it('addresses every member on @everyone, only the named one on a bare mention, nobody without a mention', async () => {+ const { rounds, membership } = await loadRoom()+ const keysOf = (members: GroupMember[]) => members.map(member => membership.groupMemberKey(member))++ expect([...rounds.explicitlyAddressedMemberKeys(user('@everyone standup'), MEMBERS)].sort()).toEqual(+ [...keysOf(MEMBERS)].sort()+ )+ expect([...rounds.explicitlyAddressedMemberKeys(user('@builder take this one'), MEMBERS)]).toEqual([+ membership.groupMemberKey(MEMBERS[1])+ ])+ expect(rounds.explicitlyAddressedMemberKeys(user('fyi, deploy went out'), MEMBERS).size).toBe(0)+ })++ it('never counts a member reply\'s @handoff as a user address', async () => {+ const { rounds, membership } = await loadRoom()++ const entries: GroupMessage[] = [+ ...user('@builder take this one'),+ { at: 2, from: { kind: 'member', name: 'builder' }, text: 'on it — @research can you dig in?' } as GroupMessage+ ]++ expect([...rounds.explicitlyAddressedMemberKeys(entries, MEMBERS)]).toEqual([+ membership.groupMemberKey(MEMBERS[1])+ ])+ })+})++describe('an addressed member that (pass)ed', () => {+ it('gets one nudge and its recovered reply is posted to the room', async () => {+ const room = await loadRoom({+ turn: ({ prompt }) => (prompt.includes('explicitly addressed') ? 'here is my answer' : '(pass)')+ })++ room.rounds.sendToGroupChat('Nudge', MEMBERS, '@builder status?')+ await settle(room, 'Nudge')++ const builderCalls = room.gateway.calls.filter(call => call.profile === 'builder')++ expect(builderCalls).toHaveLength(2)+ expect(builderCalls[0].prompt).not.toContain('explicitly addressed')+ expect(builderCalls[1].prompt).toContain('explicitly addressed')+ expect(+ log(room, 'Nudge')+ .filter(entry => entry.from.kind === 'member')+ .map(entry => entry.text)+ ).toEqual(['here is my answer'])+ expect(room.activity.currentGroupActivity('Nudge').filter(event => event.kind === 'failed')).toEqual([])+ })++ it('records explicit noncompliance (never plain silence) when the nudge is passed on too', async () => {+ const room = await loadRoom({ turn: () => '(pass)' })++ room.rounds.sendToGroupChat('Stubborn', MEMBERS, '@builder status?')+ await settle(room, 'Stubborn')++ const builderCalls = room.gateway.calls.filter(call => call.profile === 'builder')++ expect(builderCalls).toHaveLength(2)+ expect(log(room, 'Stubborn').filter(entry => entry.from.kind === 'member')).toEqual([])+ expect(room.activity.currentGroupActivity('Stubborn').filter(event => event.kind === 'failed')).toEqual([+ expect.objectContaining({+ kind: 'failed',+ member: room.membership.groupMemberKey(MEMBERS[1]),+ reason: 'explicitly addressed member passed twice'+ })+ ])+ })++ it('leaves an ordinary collaborative pass alone (no mention, no nudge, no failure)', async () => {+ const room = await loadRoom({ turn: () => '(pass)' })++ room.rounds.sendToGroupChat('Quiet', MEMBERS, 'fyi, deploy went out')+ await settle(room, 'Quiet')++ expect(room.gateway.calls).toHaveLength(2)+ expect(room.gateway.calls.every(call => !call.prompt.includes('explicitly addressed'))).toBe(true)+ expect(log(room, 'Quiet')).toHaveLength(1)+ expect(log(room, 'Quiet')[0].from.kind).toBe('user')+ expect(room.activity.currentGroupActivity('Quiet').filter(event => event.kind === 'failed')).toEqual([])+ })+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.tsindex 4542b050ff5..ada01e789ed 100644--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts@@ -447,8 +447,12 @@ describe('round lifecycle', () => {room.rounds.sendToGroupChat('Failure', members, '@research explicitly retry', thread)await settle(room, 'Failure')- expect(room.gateway.calls).toHaveLength(2)+ // Three calls: the retry itself, then the #129443 nudge — the retry send+ // @-addressed research and its "(pass)" is re-asked once, not retried by+ // the ambiguous-submit path.+ expect(room.gateway.calls).toHaveLength(3)expect(room.gateway.calls[1].prompt).toMatch(/first[\s\S]*queued same-thread[\s\S]*explicitly retry/)+ expect(room.gateway.calls[2].prompt).toContain('explicitly addressed')})it('attributes a queued drive failure to the thread whose harvest failed', async () => {@@ -459,7 +463,11 @@ describe('round lifecycle', () => {})const room = await loadRoom({ turn: () => held })- const first = room.rounds.sendToGroupChat('Failure', MEMBERS.slice(0, 2), '@research first')!+ // First send addresses nobody (@-addressing research would engage the+ // #129443 nudge on its "(pass)" — noise this attribution test does not+ // care about), so it drives research alone through the single-member+ // roster.+ const first = room.rounds.sendToGroupChat('Failure', [MEMBERS[0]], 'first')!await drain(() => room.gateway.calls.length < 1)const queued = room.rounds.sendToGroupChat('Failure', MEMBERS.slice(0, 2), '@builder queued')!const request = host.request as (...args: unknown[]) => Promise<unknown>@@ -893,7 +901,10 @@ describe('attachments', () => {)await settle(room, 'Scoped')- expect(room.gateway.attaches.map(entry => entry.profile)).toEqual(['builder'])+ // Two stagings, both for builder: the turn itself, then the #129443 nudge+ // re-ask (the send @-addressed builder and the default script "(pass)"ed)+ // — the re-ask carries the same context, attachment included.+ expect(room.gateway.attaches.map(entry => entry.profile)).toEqual(['builder', 'builder'])})it('accepts an image-only send and carries the attachment on the room entry', async () => {@@ -1265,7 +1276,9 @@ describe('member holds (#93129)', () => {room.rounds.sendToGroupChat('No holds', member, 'stop @research but answer this')await settle(room, 'No holds')- expect(room.gateway.calls).toHaveLength(1)+ // Two calls: the turn plus the #129443 nudge — the send @-addressed+ // research, so its default "(pass)" is re-asked once even here.+ expect(room.gateway.calls).toHaveLength(2)expect(room.chat.$groupChats.get()['No holds'].holds).toEqual({})await room.rounds.stopGroupThread('No holds', null, member)expect(room.chat.$groupChats.get()['No holds'].holds).toEqual({})diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.tsindex 18d53bd033f..6978cea8cf1 100644--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.ts@@ -204,6 +204,53 @@ export function resolveGroupResponders(log: GroupMessage[], members: GroupMemberreturn members.filter(member => mentioned.has(groupMemberKey(member)))}+/** #129443: member keys the thread's user sends EXPLICITLY addressed —+ * @everyone expands to every member, a bare @mention to just the mentioned+ * ones, and a send with no mention at all to nobody (that turn is+ * collaborative, so an ordinary "(pass)" stays legitimate silence). Only+ * user entries are scanned: a member's @handoff inside its own reply is the+ * #94478 continuation's business, not this addressing state. This is the+ * structured address the pass path consults, so a directly addressed+ * member can never settle the room silently. */+export function explicitlyAddressedMemberKeys(log: GroupMessage[], members: GroupMember[]) {+ let sinceLastUser: GroupMessage[] = []++ for (let i = log.length - 1; i >= 0; i--) {+ if (log[i].from.kind === 'user') {+ sinceLastUser = log.slice(i)++ break+ }+ }++ const keys = new Set<string>()+ let everyone = false++ for (const entry of sinceLastUser) {+ if (entry.from.kind !== 'user') {+ continue+ }++ const parsed = parseGroupChatMentions(entry.text, members)++ if (parsed.everyone) {+ everyone = true+ }++ for (const key of parsed.mentioned) {+ keys.add(key)+ }+ }++ if (everyone) {+ for (const member of members) {+ keys.add(groupMemberKey(member))+ }+ }++ return keys+}+/** Rotate the roster so a different member leads each round. */export function rotateGroupSpeakers(members: GroupMember[], round: number) {if (members.length < 2) {@@ -584,6 +631,14 @@ export async function runGroupChatRounds(const startEpoch = ($groupChats.get()[group] || {}).epoch || 0const isCurrent = () => binding.isLive() && (($groupChats.get()[group] || {}).epoch || 0) === startEpoch+ // #129443: the driving send's explicit addresses, frozen for the whole+ // drive — mid-drive member handoffs stay the #94478 continuation's job.+ const startLog = (($groupChats.get()[group] || {}).log || []).filter(+ (e: GroupMessage) => groupThreadOf(e) === thread+ )++ const addressedKeys = explicitlyAddressedMemberKeys(startLog, members)+const context = {get group() {return group@@ -592,6 +647,7 @@ export async function runGroupChatRounds(thread,startEpoch,failedMembers,+ addressedKeys,binding,isCurrent}