The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): group rooms wake on @all, ignore prose stop words, report dead turns, approve on click
teknium1b466a87bd6e1
diff --git a/apps/desktop/e2e/group-approval-click-submits.spec.ts b/apps/desktop/e2e/group-approval-click-submits.spec.tsnew file mode 100644index 00000000000..26030a42c4e--- /dev/null+++ b/apps/desktop/e2e/group-approval-click-submits.spec.ts@@ -0,0 +1,115 @@+import { APPROVAL_COMMAND_TRIGGER, MOCK_REPLY } from '../../../tests-js/scripts/mock-server'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// #91706: a command-approval card in a Bot Mode group room could highlight+// the clicked choice but never send it — the footer "Respond" button was+// off-screen or covered, so the member's hidden session stayed blocked until+// the approval expired. Approvals are a closed choice set: the click IS the+// answer. Driven against the real Electron app, a real gateway with+// `approvals: mode: "manual"`, and mock inference that runs a gated+// `rm -rf` through the real terminal tool.++const ROOM = 'Programmer, Reviewer'+let fixture: MockBackendFixture | null = null++async function openBots(page: MockBackendFixture['page']): Promise<void> {+ const tab = page.getByRole('button', { name: 'Bots', exact: true }).or(page.getByRole('tab', { name: 'Bots', exact: true })).first()+ await tab.click()+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()+}++async function createAgent(page: MockBackendFixture['page'], name: string, title: string): Promise<void> {+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Bot' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Bot' })+ await dialog.getByPlaceholder('inbox-triage').fill(name)+ await dialog.getByPlaceholder('Inbox Triage').fill(title)+ await dialog.getByRole('button', { name: 'Create Bot' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })+ await expect(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: MockBackendFixture['page']) {+ await openBots(page)+ await createAgent(page, 'programmer', 'Programmer')+ await createAgent(page, 'reviewer', 'Reviewer')++ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Group Chat' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })++ for (const title of ['Programmer', 'Reviewer']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const groupTab = page.getByRole('tab', { name: new RegExp(`${ROOM} Close`) })+ const groupComposer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(groupTab).toBeVisible({ timeout: 20_000 })+ await expect(groupTab).toHaveAttribute('aria-selected', 'true')+ await expect(groupComposer).toBeVisible()++ return groupComposer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({ extraConfig: 'approvals:\n mode: "manual"\n' })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('clicking an approval choice in a group room submits it (#91706)', async () => {+ test.setTimeout(240_000)+ const page = fixture!.page+ // Count approval.respond frames on the real gateway socket.+ await page.evaluate(() => {+ const send = WebSocket.prototype.send++ ;(window as any).__approvalResponds = [] as string[]++ WebSocket.prototype.send = function (data) {+ const frame = JSON.parse(String(data))++ if (frame.method === 'approval.respond') {+ ;(window as any).__approvalResponds.push(JSON.stringify(frame.params))+ }++ return send.call(this, data)+ }+ })+ const groupComposer = await createRoom(page)++ await groupComposer.fill(`@programmer ${APPROVAL_COMMAND_TRIGGER}`)+ await groupComposer.press('Enter')++ // The member's gated terminal command surfaces as an approval card in the room.+ const once = page.getByRole('button', { name: 'once', exact: true })+ await expect(once).toBeVisible({ timeout: 90_000 })+ await expect(page.getByText(/wants to run a command/)).toBeVisible()+ console.log('APPROVAL CARD: visible; responds so far =', await page.evaluate(() => (window as any).__approvalResponds.length))+ await page.screenshot({ path: test.info().outputPath('approval-card.png') })++ await once.click()++ // One approval.respond leaves the Desktop for the click itself — no second+ // "Respond" click required (there is none to click for approvals).+ await expect.poll(() => page.evaluate(() => (window as any).__approvalResponds.length), { timeout: 15_000 }).toBe(1)+ await expect(page.getByRole('button', { name: 'Respond', exact: true })).toHaveCount(0)+ expect(await page.evaluate(() => (window as any).__approvalResponds[0])).toContain('once')++ // The blocked member resumes: the command runs and its reply lands in the room.+ await expect(page.getByText(MOCK_REPLY, { exact: true }).first()).toBeVisible({ timeout: 90_000 })+ await expect(once).toHaveCount(0)+ console.log('APPROVAL: submitted on click; responds =', await page.evaluate(() => (window as any).__approvalResponds))+ await page.screenshot({ path: test.info().outputPath('approval-after.png') })+})diff --git a/apps/desktop/e2e/group-hold-directive.spec.ts b/apps/desktop/e2e/group-hold-directive.spec.tsnew file mode 100644index 00000000000..b7da6b8d8b3--- /dev/null+++ b/apps/desktop/e2e/group-hold-directive.spec.ts@@ -0,0 +1,130 @@+import { MOCK_REPLY } from '../../../tests-js/scripts/mock-server'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// Sticky Stop holds (#93129) are set and released by the hold classifier in+// group-rounds.ts. Two community reports against it:+// #103893 — a German room's filler word ("@impl go, das ist halt ein Test")+// held the mentioned bot on every resend;+// #97740 — a room stopped with the Stop button stayed silent for "@all <task>"+// because only the literal "@all resume" released the holds.+// Both are asserted against the real Electron app + real gateway + mock+// inference: the member's prompt must reach the provider, and the persisted+// room record must carry no hold.++const ROOM = 'Programmer, Reviewer'+const FIRST_REPLY = 'FIRST_REPLY: initial work completed'+let fixture: MockBackendFixture | null = null++async function roomHolds(page: MockBackendFixture['page']) {+ return page.evaluate(name => {+ const rooms = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')++ return Object.keys(rooms[name]?.holds || {})+ }, ROOM)+}++async function openBots(page: MockBackendFixture['page']): Promise<void> {+ const tab = page.getByRole('button', { name: 'Bots', exact: true }).or(page.getByRole('tab', { name: 'Bots', exact: true })).first()+ await tab.click()+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()+}++async function createAgent(page: MockBackendFixture['page'], name: string, title: string): Promise<void> {+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Bot' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Bot' })+ await dialog.getByPlaceholder('inbox-triage').fill(name)+ await dialog.getByPlaceholder('Inbox Triage').fill(title)+ await dialog.getByRole('button', { name: 'Create Bot' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })+ await expect(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: MockBackendFixture['page']) {+ await openBots(page)+ await createAgent(page, 'programmer', 'Programmer')+ await createAgent(page, 'reviewer', 'Reviewer')++ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Group Chat' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })++ for (const title of ['Programmer', 'Reviewer']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const groupTab = page.getByRole('tab', { name: new RegExp(`${ROOM} Close`) })+ const groupComposer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(groupTab).toBeVisible({ timeout: 20_000 })+ await expect(groupTab).toHaveAttribute('aria-selected', 'true')+ await expect(groupComposer).toBeVisible()++ return groupComposer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({ mockServer: {+ holdFirstCompletionContaining: 'LANE_H_FIRST',+ replyForPrompt: prompt => prompt.includes('LANE_H_FIRST') ? FIRST_REPLY : MOCK_REPLY+ } })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a distant German filler word does not hold the mentioned bot (#103893)', async () => {+ test.setTimeout(240_000)+ const page = fixture!.page+ const groupComposer = await createRoom(page)++ await groupComposer.fill('@programmer go, das ist halt ein Test LANE_H_GERMAN')+ await groupComposer.press('Enter')++ // The bot was addressed: its turn prompt must reach the provider ...+ await expect.poll(() => fixture!.mock.receivedPrompts.some(p => p.includes('LANE_H_GERMAN')), { timeout: 60_000 }).toBe(true)+ // ... and the persisted room record must not carry a hold for it.+ expect(await roomHolds(page)).toEqual([])+ await expect(page.getByText(MOCK_REPLY, { exact: true }).first()).toBeVisible({ timeout: 60_000 })+ await expect(page.locator('[data-slot="group-hold-status"]')).toHaveCount(0)+ console.log('GERMAN FILLER: prompt delivered, holds =', JSON.stringify(await roomHolds(page)))+ await page.screenshot({ path: test.info().outputPath('german-filler-after.png') })+})++test('@all with a task re-engages a room the user stopped (#97740)', async () => {+ test.setTimeout(240_000)+ const page = fixture!.page+ const groupComposer = await createRoom(page)++ await groupComposer.fill('@programmer LANE_H_FIRST')+ await groupComposer.press('Enter')+ await fixture!.mock.waitForHeldCompletion()+ await page.getByRole('button', { name: 'Stop', exact: true }).click()+ fixture!.mock.releaseHeldStream()+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0)+ // Stop holds every member durably.+ await expect.poll(() => roomHolds(page)).toHaveLength(2)+ // The durable room status (#99094) names the held members.+ await expect(page.locator('[data-slot="group-hold-status"]')).toBeVisible()+ console.log('STOPPED: holds =', JSON.stringify(await roomHolds(page)))+ await page.screenshot({ path: test.info().outputPath('all-task-stopped.png') })++ // No "resume" anywhere: addressing the whole room is the release.+ await groupComposer.fill('@all LANE_H_ALLTASK tell me a joke each')+ await groupComposer.press('Enter')+ await expect.poll(() => fixture!.mock.receivedPrompts.filter(p => p.includes('LANE_H_ALLTASK')).length, { timeout: 90_000 }).toBeGreaterThanOrEqual(2)+ expect(await roomHolds(page)).toEqual([])+ await expect(page.locator('[data-slot="group-hold-status"]')).toHaveCount(0)+ await expect(page.getByText(MOCK_REPLY, { exact: true }).first()).toBeVisible({ timeout: 60_000 })+ console.log('@all TASK: prompts delivered to', fixture!.mock.receivedPrompts.filter(p => p.includes('LANE_H_ALLTASK')).length, 'members; holds =', JSON.stringify(await roomHolds(page)))+ await page.screenshot({ path: test.info().outputPath('all-task-after.png') })+})diff --git a/apps/desktop/e2e/group-member-backend-failure.spec.ts b/apps/desktop/e2e/group-member-backend-failure.spec.tsnew file mode 100644index 00000000000..7adbda62f17--- /dev/null+++ b/apps/desktop/e2e/group-member-backend-failure.spec.ts@@ -0,0 +1,96 @@+import { PROVIDER_FAILURE_TRIGGER } from '../../../tests-js/scripts/mock-server'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// #92760 "thinks then never speaks": when a member's backend fails the turn+// (bad credentials, provider refusal), the gateway keeps the failed turn under+// `session.resume.inflight` as `{ status: 'error' }` so a reconnecting client+// can rebuild the error bubble. The room engine read that truthy object as+// "still working" and kept extending the member's deadline toward the+// 20-minute cap — the user saw a bot thinking forever with no error anywhere.+// Real Electron + real gateway; the mock provider answers the member with a+// non-retryable 401.++const ROOM = 'Programmer, Reviewer'+let fixture: MockBackendFixture | null = null++async function openBots(page: MockBackendFixture['page']): Promise<void> {+ const tab = page.getByRole('button', { name: 'Bots', exact: true }).or(page.getByRole('tab', { name: 'Bots', exact: true })).first()+ await tab.click()+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()+}++async function createAgent(page: MockBackendFixture['page'], name: string, title: string): Promise<void> {+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Bot' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Bot' })+ await dialog.getByPlaceholder('inbox-triage').fill(name)+ await dialog.getByPlaceholder('Inbox Triage').fill(title)+ await dialog.getByRole('button', { name: 'Create Bot' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })+ await expect(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: MockBackendFixture['page']) {+ await openBots(page)+ await createAgent(page, 'programmer', 'Programmer')+ await createAgent(page, 'reviewer', 'Reviewer')++ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Group Chat' }).click()++ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })++ for (const title of ['Programmer', 'Reviewer']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const groupTab = page.getByRole('tab', { name: new RegExp(`${ROOM} Close`) })+ const groupComposer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(groupTab).toBeVisible({ timeout: 20_000 })+ await expect(groupTab).toHaveAttribute('aria-selected', 'true')+ await expect(groupComposer).toBeVisible()++ return groupComposer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend()+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a member whose backend fails the turn is reported at once, not read as busy (#92760)', async () => {+ test.setTimeout(240_000)+ const page = fixture!.page+ const groupComposer = await createRoom(page)++ await groupComposer.fill(`@programmer ${PROVIDER_FAILURE_TRIGGER}`)+ await groupComposer.press('Enter')+ await expect.poll(() => fixture!.mock.receivedPrompts.some(p => p.includes(PROVIDER_FAILURE_TRIGGER)), { timeout: 60_000 }).toBe(true)++ // The gateway has failed the turn; the room must say so within the base+ // turn timeout instead of extending the deadline on the retained snapshot.+ const activity = page.getByRole('button', { name: /^Activity/ })+ await expect(activity).toContainText('Programmer hit an error', { timeout: 120_000 })+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0, { timeout: 30_000 })++ const room = await page.evaluate(name => {+ const rooms = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')++ return { stranded: Object.keys(rooms[name]?.stranded || {}), running: Boolean(rooms[name]?.running) }+ }, ROOM)++ expect(room.stranded).toEqual([])+ console.log('RETAINED FAILURE: activity =', await activity.textContent(), 'room =', JSON.stringify(room))+ await page.screenshot({ path: test.info().outputPath('retained-failure-after.png') })+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsxindex cca1e0a4648..fe227f5016c 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.test.tsx@@ -225,3 +225,40 @@ describe('keyboard (#89884)', () => {expect(onSubmitDraft).not.toHaveBeenCalled()})})++// #91706: a command approval in a room could be SELECTED but never sent — the+// footer "Respond" button sat off-screen or under an overflowing code block.+// Approvals are a closed choice set, so the click itself is the answer.+describe('approval card (#91706)', () => {+ const entry = {+ at: 1,+ choices: ['once', 'session', 'always', 'deny'],+ command: 'rm -rf /tmp/scratch',+ group: 'Core',+ kind: 'approval' as const,+ member: 'alpha',+ memberKey: 'alpha',+ multiSelect: false,+ question: '',+ requestId: 'req-1',+ sessionId: 'sid-1',+ thread: 't1'+ }++ it('submits the clicked choice at once, with no second Respond click', async () => {+ const answer = vi.fn(async () => undefined)+ vi.doMock('./group-turns', () => ({ answerGroupClarify: answer }))+ vi.doMock('./group-chat', () => ({ appendGroupChatEntry: vi.fn() }))+ const { GroupClarifyCard } = await import('./group-chat-parts')++ render(<GroupClarifyCard entry={entry} members={MEMBERS} />)++ expect(screen.queryByRole('button', { name: 'Respond' })).toBeNull()+ fireEvent.click(screen.getByRole('button', { name: 'once' }))+ // A second click while the first is in flight must not double-submit.+ fireEvent.click(screen.getByRole('button', { name: 'session' }))++ await vi.waitFor(() => expect(answer).toHaveBeenCalledTimes(1))+ expect(answer).toHaveBeenCalledWith(entry, MEMBERS[0], 'once')+ })+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsxindex d157be5be84..3611613abe1 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-parts.tsx@@ -416,8 +416,13 @@ export function GroupClarifyCard({ entry, members }: GroupClarifyCardProps) {const allAnswered = questions.every(q => answerFor(q))- const submit = async () => {- if (!member || sending || !allAnswered) {+ /** `chosen` short-circuits the staged answer: approval choices submit on+ * click (#91706), so the value travels with the click instead of waiting+ * for a re-render of `picked` and a second Respond click. */+ const submit = async (chosen?: string) => {+ const resolve = (q: GroupClarifyQuestion) => chosen ?? answerFor(q)++ if (!member || sending || !questions.every(q => resolve(q))) {return}@@ -425,12 +430,12 @@ export function GroupClarifyCard({ entry, members }: GroupClarifyCardProps) {try {if (isApproval || !(entry.questions && entry.questions.length)) {- await answerGroupClarify(entry, member, answerFor(questions[0]))+ await answerGroupClarify(entry, member, resolve(questions[0]))} else {const answers: Record<string, string> = {}for (const q of questions) {- answers[q.qid] = answerFor(q)+ answers[q.qid] = resolve(q)}await answerGroupClarify(entry, member, answers)@@ -438,8 +443,8 @@ export function GroupClarifyCard({ entry, members }: GroupClarifyCardProps) {// Echo the exchange into the room log so the thread reads complete.const summary = isApproval- ? `${answerFor(questions[0])} — ${entry.command || entry.question || b.group.commandApproval}`- : questions.map(q => (questions.length > 1 ? `${q.question}: ${answerFor(q)}` : answerFor(q))).join('\n')+ ? `${resolve(questions[0])} — ${entry.command || entry.question || b.group.commandApproval}`+ : questions.map(q => (questions.length > 1 ? `${q.question}: ${resolve(q)}` : resolve(q))).join('\n')appendGroupChatEntry(group,@@ -487,8 +492,22 @@ export function GroupClarifyCard({ entry, members }: GroupClarifyCardProps) {'h-6 px-2 text-[0.7rem]',isApproval && choice === 'deny' && !chosen && 'text-destructive')}+ disabled={sending || !member}key={`choice:${q.qid}:${choice}`}onClick={() => {+ // Approvals are a closed choice set: the click IS the+ // answer (#91706). Staging it behind a footer button+ // left users with a highlighted choice and no way to+ // send it when the footer was clipped or covered.+ if (isApproval) {+ setPicked({+ [q.qid]: [choice]+ })+ void submit(choice)++ return+ }+setDrafts(prev => ({...prev,[q.qid]: ''@@ -553,11 +572,14 @@ export function GroupClarifyCard({ entry, members }: GroupClarifyCardProps) {)}</div>))}- <div className="flex justify-end">- <Button disabled={sending || !allAnswered || !member} onClick={() => void submit()} size="sm">- {sending ? 'Sending…' : isApproval ? 'Respond' : 'Answer'}- </Button>- </div>+ {/* Approval choices submit on click; only clarify answers need a footer. */}+ {isApproval ? null : (+ <div className="flex justify-end">+ <Button disabled={sending || !allAnswered || !member} onClick={() => void submit()} size="sm">+ {sending ? 'Sending…' : 'Answer'}+ </Button>+ </div>+ )}</div>)}diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.tsindex fde3a7d2899..3819d7e0563 100644--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts@@ -855,6 +855,36 @@ describe('member holds (#93129)', () => {expect([...action.release]).toEqual(['impl'])})+ // #103893: a German room said "@impl go, das ist halt ein Test" and the+ // filler "halt" four words away from the mention held the bot every time+ // the text was resent. Only a stop word next to a mention is a directive.+ it('treats a stop word far from every mention as prose, not a directive', async () => {+ const { rounds } = await loadRoom()++ for (const text of ['@impl go, das ist halt ein Test', '@impl mach mal Pause', 'stop the presses, @impl what do you think?']) {+ const action = rounds.classifyGroupHoldDirective(text, ['conn::impl'], false)++ expect([...action.hold]).toEqual([])+ expect([...action.release]).toEqual(['conn::impl'])+ }++ // Keys are roster keys, not handles: proximity must still hold on the raw @token.+ expect([...rounds.classifyGroupHoldDirective('@impl please halt', ['conn::impl'], false).hold]).toEqual(['conn::impl'])+ })++ // #97740: a room stopped by the user went permanently silent because only+ // the literal "@all resume" released the holds; "@all <task>" addresses+ // every member and must re-engage them like a direct mention does.+ it('releases every hold when the whole room is addressed without a stop word', async () => {+ const { rounds } = await loadRoom()+ const held = { docs: { at: 2 }, impl: { at: 1 } }++ expect(rounds.applyGroupHoldDirective(held, { everyone: true, mentioned: [] }, '@all tell me a joke each', {})).toEqual({})+ expect(rounds.applyGroupHoldDirective(held, { everyone: true, mentioned: [] }, '@all stop', { at: 5 }, ['impl', 'docs'])).not.toEqual({})+ // An unaddressed message still leaves the holds alone.+ expect(rounds.applyGroupHoldDirective(held, { everyone: false, mentioned: [] }, 'anyone there?', {})).toBe(held)+ })+it('sets a hold on stop and clears it on resume for the same member', async () => {const { rounds } = await loadRoom()const stamp = { at: 1000, byMessageId: 'm1', thread: 't1' }diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.tsindex 734c149475b..7a427e87eb9 100644--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.ts@@ -197,13 +197,19 @@ export function rotateGroupSpeakers(members: GroupMember[], round: number) {/** #93129: classify a USER room message's effect on member holds. Only user* sends ever reach this (bot replies are appended by the round loop, never* through sendToGroupChat), so a bot saying "stopped working on it" can- * never set a hold. Conservative on purpose: any standalone stop/halt/pause- * word next to a mention holds those members — "don't stop @x" therefore- * also holds, which errs toward the bot staying quiet until re-addressed- * (a wrongly-held bot is one mention away from release; a wrongly-running- * one keeps doing work it was told to stop). A non-stop direct mention- * releases the mentioned members — the user addressing a bot directly- * overrides its hold. */+ * never set a hold. Conservative on purpose: a standalone stop/halt/pause+ * word NEXT TO a mention (within two words, #103893) holds those members —+ * "don't stop @x" therefore also holds, which errs toward the bot staying+ * quiet until re-addressed (a wrongly-held bot is one mention away from+ * release; a wrongly-running one keeps doing work it was told to stop).+ * A stop word far from every mention is prose, not a directive: "@x go,+ * das ist halt ein Test" and "@x mach mal Pause" address the bot, so+ * non-English rooms whose everyday vocabulary overlaps the keyword list+ * are not silently held. A non-stop direct mention releases the mentioned+ * members — the user addressing a bot directly overrides its hold — and+ * addressing the whole room (@all / @everyone) without a stop word is the+ * same intent for every member (#97740): "@all <task>" wakes a stopped+ * room without the user having to know the literal "resume" incantation. */export function classifyGroupHoldDirective(text: string,mentionedKeys: Iterable<string> | null | undefined,@@ -211,8 +217,7 @@ export function classifyGroupHoldDirective() {const value = String(text || '')const mentioned = [...(mentionedKeys || [])]- const stop = /\b(stop|halt|pause)\b/i.test(value)- const resume = /\b(resume|continue|go|proceed)\b/i.test(value)+ const stop = stopWordNearMention(value)if (stop) {// "@all stop" holds every member — symmetric with "@all resume".@@ -224,23 +229,38 @@ export function classifyGroupHoldDirective(}}- if (resume) {- return {- hold: [],- holdAll: false,- release: mentioned,- releaseAll: Boolean(everyone)- }- }-return {hold: [],holdAll: false,release: mentioned,- releaseAll: false+ releaseAll: Boolean(everyone)}}+/** #103893: true when a stop/halt/pause token sits within two words of ANY+ * @token in the message. Proximity is measured against the raw @tokens,+ * not the resolved member keys the caller passes (those are roster keys+ * such as `<connectionId>::<name>`, and a mention resolves through titles+ * and friendly names too, so the @token text rarely equals the key). The+ * ≤2 window is fitted to observed directive/filler pairs ("@x please+ * halt" = 2, "@x go, das ist halt ein Test" = 4); widen only with measured+ * cases, never by guessing. */+function stopWordNearMention(value: string) {+ const tokens = value.toLowerCase().match(/@[\p{L}\p{N}._-]+|[\p{L}\p{N}_-]+/gu) || []+ const mentionAt: number[] = []+ const stopAt: number[] = []++ tokens.forEach((token, index) => {+ if (token.startsWith('@')) {+ mentionAt.push(index)+ } else if (token === 'stop' || token === 'halt' || token === 'pause') {+ stopAt.push(index)+ }+ })++ return stopAt.some(stop => mentionAt.some(mention => Math.abs(stop - mention) <= 2))+}+/** What `parseGroupChatMentions` reports for one room message. */interface GroupMentionParse {everyone?: booleandiff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.tsindex 100c216db83..4594f43137a 100644--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts@@ -102,6 +102,10 @@ export interface GatewayOptions {onResumePoll?: (polls: number) => void/** Report the member inflight for the first N post-submit polls. */pollsBusy?: number+ /** After a submit, every resume replays the gateway's RETAINED failed turn+ * (`inflight: { status: 'error', error }`, `running: false`) instead of a+ * reply — the snapshot `_fail_inflight_turn` leaves for reconnecting clients. */+ retainedErrorAfterSubmit?: stringturn?: TurnScript}@@ -269,8 +273,13 @@ export function createGroupGateway(options: GatewayOptions = {}): ScriptedGatewaconst clarify = options.clarifyUntil?.[session.profile]const approval = options.approvalUntil?.[session.profile]+ const retained =+ options.retainedErrorAfterSubmit && session.messages.at(-1)?.role === 'user'+ ? { error: options.retainedErrorAfterSubmit, status: 'error', streaming: false }+ : null+return {- inflight: busy,+ inflight: retained ?? busy,message_count: busy ? 0 : session.messages.length,messages: busy || params.omit_messages ? [] : [...session.messages],running: false,diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.test.tsindex 6b155650c5a..b8306552477 100644--- a/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts@@ -303,6 +303,32 @@ describe('session-gone classification', () => {)expect(room.gateway.rpcFor('prompt.submit')).toHaveLength(1)})++ // #92760 silent stall (#95103): the gateway RETAINS a failed turn under+ // `inflight` as `{ status: 'error', … }` so reconnecting clients can rebuild+ // the error. Read as "busy", that tombstone kept sliding the deadline to the+ // 20-minute cap and the member looked like it was thinking forever.+ it('surfaces a retained failed turn immediately instead of waiting on it as live work', async () => {+ // Each clock read jumps a minute: a loop that keeps extending the deadline+ // hits the hard cap in a bounded number of polls instead of spinning.+ let now = 1_000_000+ const clock = vi.spyOn(Date, 'now').mockImplementation(() => (now += 60_000))+ const room = await loadRoom({ retainedErrorAfterSubmit: 'No usable credentials found', turn: () => [] })++ try {+ await expect(room.turns.runGroupChatMemberTurn('Room', LOCAL_MEMBER, 'hi', 't1', [])).rejects.toThrow(+ 'No usable credentials found'+ )+ // The submit itself succeeded once; no timed-out/stranded marker was left behind.+ expect(room.gateway.rpcFor('prompt.submit')).toHaveLength(1)+ expect(room.chat.$groupChats.get().Room?.stranded?.helper).toBeUndefined()+ expect(room.turns.groupSessionBusy({ inflight: { status: 'error' }, running: false })).toBe(false)+ expect(room.turns.groupSessionBusy({ inflight: { status: 'streaming' }, running: false })).toBe(true)+ expect(room.turns.groupSessionBusy({ inflight: true })).toBe(true)+ } finally {+ clock.mockRestore()+ }+ })})describe('per-turn socket lease', () => {diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.tsindex cd7f5f22992..8903efee0f7 100644--- a/apps/desktop/src/plugins/hermes-bots/group-turns.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.ts@@ -8,6 +8,7 @@import { host } from '@hermes/plugin-sdk'+import { noteBotAttention } from './data'import { recordGroupActivity } from './group-activity'import { $groupChats, $groupClarify, appendGroupChatEntry, updateGroupChat } from './group-chat'import type { GroupChatRoom } from './group-chat'@@ -104,7 +105,10 @@ interface GroupPendingApproval {/** The `session.resume` fields the room engine reads off a member's hidden* per-group session. */interface GroupSessionSnapshot {- inflight?: boolean+ /** `true`/`false` on older gateways; current ones replay the in-flight turn+ * object, which after a failure is RETAINED as `{ status: 'error', … }`+ * (`_fail_inflight_turn`) so a reconnecting client can rebuild the error. */+ inflight?: boolean | { error?: string; status?: string }message_count?: numbermessages?: GroupTurnTranscriptMessage[]/** Still-open server→client requests (`server_requests.open_requests`); the@@ -116,6 +120,33 @@ interface GroupSessionSnapshot {session_key?: string}+/** The error message of a RETAINED failed turn, else null. The gateway keeps+ * `{ status: 'error', error }` under `inflight` after a turn dies so a+ * reconnecting client can rebuild the error bubble; it is a tombstone of+ * finished work, not live work (`prompt_turn.py` itself treats it as a+ * stale leftover when the next turn starts). */+export function retainedGroupTurnError(state: GroupSessionSnapshot | null | undefined): null | string {+ const inflight = state?.inflight++ if (inflight && typeof inflight === 'object' && inflight.status === 'error') {+ return String(inflight.error || 'turn failed')+ }++ return null+}++/** Is the member's session still doing work this turn should wait for?+ * Reading a retained failure as busy kept a dead turn's deadline sliding to+ * the 20-minute hard cap and left its stranded marker harvestable forever+ * (#92760 silent stall, diagnosed in #95103). */+export function groupSessionBusy(state: GroupSessionSnapshot | null | undefined): boolean {+ if (state?.running) {+ return true+ }++ return Boolean(state?.inflight) && retainedGroupTurnError(state) === null+}+/** A member's per-group session, resolved for one turn. */interface GroupMemberSessionHandle {/** Live runtime id every RPC in this turn targets. */@@ -871,7 +902,7 @@ async function pollGroupMemberTurn(context: GroupTurnPollContext): Promise<null}const messages = Array.isArray(state?.messages) ? state.messages : []- const busy = Boolean(state?.inflight || state?.running)+ const busy = groupSessionBusy(state)// A clarify blocking inside the member's session is a question for the// HUMAN (#90694) — mirror it into the room store so a card renders, and// hold the turn open: the member isn't stalling, it's waiting on us.@@ -891,6 +922,15 @@ async function pollGroupMemberTurn(context: GroupTurnPollContext): Promise<nullreturn replyText}+ // Our prompt landed and the turn died on it: surface the gateway's+ // retained error through the failed-turn path (activity row + roster+ // badge) instead of reading the silence as a pass.+ const failure = retainedGroupTurnError(state)++ if (failure !== null) {+ throw new Error(failure)+ }+recordGroupActivity(context.group, {kind: 'passed',member: groupMemberKey(member),@@ -1077,7 +1117,7 @@ export async function harvestStrandedGroupReply(group: string, member: GroupMemb// Pending prompts are authoritative even while the session is running.const awaitingUser = syncGroupClarify(group, member, strandedThread, state)- if (state?.inflight || state?.running || awaitingUser) {+ if (groupSessionBusy(state) || awaitingUser) {return}@@ -1100,6 +1140,21 @@ export async function harvestStrandedGroupReply(group: string, member: GroupMembconst reply = pickGroupTurnReply(messages, strandedBefore)+ if (reply === null) {+ // The late turn died instead of answering: say so where the user looks+ // (activity row + roster badge) rather than consuming the marker silently.+ const failure = retainedGroupTurnError(state)++ if (failure !== null) {+ recordGroupActivity(group, {+ kind: 'failed',+ member: member.name,+ thread: strandedThread+ })+ noteBotAttention(memberKey, failure)+ }+ }+if (reply && !isGroupPassText(reply)) {recordGroupActivity(group, {kind: 'delivered',diff --git a/tests-js/scripts/mock-server.ts b/tests-js/scripts/mock-server.tsindex c02d71a3b7b..cb88efb3319 100644--- a/tests-js/scripts/mock-server.ts+++ b/tests-js/scripts/mock-server.ts@@ -351,6 +351,15 @@ const TASK_PANEL_RESUME_SCRIPT: ScriptedTurn[] = [},]+/**+ * A marker that makes the mock answer the completion with a non-retryable+ * provider failure (401 invalid key). The gateway then fails the member's+ * turn and RETAINS it under `session.resume.inflight` as `{ status: 'error' }`+ * — the tombstone a Bot Mode room must read as "finished", not "still busy".+ */+export const PROVIDER_FAILURE_TRIGGER = 'E2E_PROVIDER_FAILURE_TRIGGER'+export const PROVIDER_FAILURE_MESSAGE = 'E2E invalid_api_key: the mock refused this completion on purpose'+const BLOCKING_CLARIFY_TURN: ScriptedTurn = {text: '',toolCalls: [{ name: 'clarify', args: { question: BLOCKING_CLARIFY_QUESTION, choices: ['Yes', 'No'] } }],@@ -390,6 +399,38 @@ function includesBatchClarifyTrigger(value: unknown): boolean {return false}+/**+ * A marker that makes the mock run a recursive delete through the real+ * `terminal` tool. Under `approvals: mode: "manual"` the backend parks the+ * turn behind a command-approval prompt (once/session/always/deny), which is+ * how a Bot Mode group room gets its approval card. The path is a scratch+ * directory so an approved run is harmless; once the tool result is in the+ * history the mock falls through to the canned reply.+ */+export const APPROVAL_COMMAND_TRIGGER = 'E2E_APPROVAL_COMMAND_TRIGGER'+export const APPROVAL_COMMAND = 'rm -rf /tmp/hermes-e2e-approval-probe'++const APPROVAL_COMMAND_TURN: ScriptedTurn = {+ text: '',+ toolCalls: [{ name: 'terminal', args: { command: APPROVAL_COMMAND } }],+}++function includesApprovalCommandTrigger(value: unknown): boolean {+ if (typeof value === 'string') {+ return value.includes(APPROVAL_COMMAND_TRIGGER)+ }++ if (Array.isArray(value)) {+ return value.some(includesApprovalCommandTrigger)+ }++ if (value && typeof value === 'object') {+ return Object.values(value).some(includesApprovalCommandTrigger)+ }++ return false+}+/*** Per-speaker scripted line for Bot Mode group rooms. A room turn prompt opens* with `You are @<handle>` and quotes the user's message verbatim, so one user@@ -576,6 +617,23 @@ export function startMockServer(options: MockServerOptions = {}): Promise<MockSereturn}+ if (includesApprovalCommandTrigger(parsed.messages)) {+ // First completion scripts the gated command; once its tool+ // result is in the history, fall through to the canned reply.+ const hasToolResult = Array.isArray(parsed.messages)+ && parsed.messages.some((message: { role?: string }) => message?.role === 'tool')++ if (!hasToolResult) {+ if (stream) {+ streamScriptedTurn(res, model, APPROVAL_COMMAND_TURN)+ } else {+ nonStreamingScriptedTurn(res, model, APPROVAL_COMMAND_TURN)+ }++ return+ }+ }+if (includesBatchClarifyTrigger(parsed.messages)) {// Only the FIRST completion of the conversation scripts the batch// clarify. The trigger text stays in message history, so once the@@ -605,6 +663,13 @@ export function startMockServer(options: MockServerOptions = {}): Promise<MockSereturn}+ if (userText.includes(PROVIDER_FAILURE_TRIGGER)) {+ res.writeHead(401, { 'Content-Type': 'application/json' })+ res.end(JSON.stringify({ error: { code: 'invalid_api_key', message: PROVIDER_FAILURE_MESSAGE, type: 'invalid_request_error' } }))++ return+ }+if (isQueueStopTrigger) {const turn = QUEUE_STOP_SCRIPT[_queueStopIndex] ?? QUEUE_STOP_SCRIPT[QUEUE_STOP_SCRIPT.length - 1]_queueStopIndex++diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.mdindex 52523707346..1744efe3e7f 100644--- a/website/docs/user-guide/bot-mode.md+++ b/website/docs/user-guide/bot-mode.md@@ -95,10 +95,17 @@ Routines are plain [Hermes cron jobs](./features/cron.md) namespaced `[bot:<nameMessages sent during a member turn queue behind the active room drive, includingreplies in the same thread. They do not interrupt that member or mark unseenmessages as read. Stop cancels queued continuations and holds the members until-resumed. A quiet room watches timed-out members for another 21 minutes after the+resumed: @mention a held member, or address the whole room (`@all …` /+`@everyone …`, any wording) to release everyone — `@all resume` is not a+required incantation. `stop`, `halt` or `pause` holds a member only when the+word sits next to its @mention (`stop @bot`, `@bot please pause`); the same word+elsewhere in the sentence is ordinary prose, so a German `halt` no longer+silences the bot it was sent to. A quiet room watches timed-out members for another 21 minutes after theforeground wait ends; this observation window does not extend the turn itself.Unresolved member failures remain visible in the collapsed Activity summary after-the room settles. Expand Activity for the turn sequence; re-address the member to+the room settles — including a turn the member's backend itself failed (bad+credentials, provider errors), which is reported the moment the gateway+reports it instead of looking like twenty minutes of thinking. Expand Activity for the turn sequence; re-address the member totry again. An ambiguous submit failure is not automatically resubmitted.@@ -126,7 +133,7 @@ Use the **Move up** and **Move down** arrows beside a room to choose its positio- **One visible conversation.** Public messages and each member's reply stay readable in arrival order, with the speaker's name and timestamp. Starting another topic does not collapse earlier replies. **Reply in thread** continues that topic without reordering the room; **Activity** is a secondary status view, not a replacement for messages. Private Bot Chats remain separate.- Your message triggers up to **three serial rounds** of member turns. @-mentioned Bots respond (everyone responds when nobody is mentioned); each Bot replies briefly or passes, and the room settles when a full round stays silent.- Teammates can hand off to the primary Bot with `@hermes`, including in older saved rooms; Bots on other gateways keep their device-qualified tags (for example, `@default-vera`).-- Bots pull each other in with `@name`, and escalate real judgment calls to you with `@user` — the group row shows a **needs you** badge when that happens. Pending questions and command approvals also light that badge; resolving the last prompt clears only prompt attention, not an independent mention. Prompts follow a renamed room, while disbanding retires them even if a member's in-flight poll arrives later.+- Bots pull each other in with `@name`, and escalate real judgment calls to you with `@user` — the group row shows a **needs you** badge when that happens. Pending questions and command approvals also light that badge; resolving the last prompt clears only prompt attention, not an independent mention. A command approval in the room answers on the click itself — `once`, `session`, `always` or `deny` sends at once, with no second button to find. Prompts follow a renamed room, while disbanding retires them even if a member's in-flight poll arrives later.- Hard caps (10 messages per send, 3 rounds) keep rooms from spinning.- Each member keeps its own persistent room session, so room context survives like any other conversation.- **Not every Bot replies to every message.** Speaking is each member's own choice — a Bot replies only when it has something new to add and passes otherwise, and @-mentioning specific members scopes the round to them. Expect the members you addressed (or whoever has something to say) to speak, and the rest to stay quiet.