The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a group member's failed turn is reported, not posted as its reply
teknium1a29cf607110b
diff --git a/apps/desktop/src/plugins/hermes-bots/group-external-writes.ts b/apps/desktop/src/plugins/hermes-bots/group-external-writes.tsindex 37881d08178..ad099d6d20b 100644--- a/apps/desktop/src/plugins/hermes-bots/group-external-writes.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-external-writes.ts@@ -74,6 +74,15 @@ export const SYNTHETIC_USER_ROW_PREFIXES = ['Cronjob Response:']+/** The Hermes-authored assistant row that closes a turn which failed before+ * the model answered (a provider 401, retry exhaustion, a refusal), typed+ * `display_kind: failed_turn` by `agent/turn_failure_copy.py`. A transcript+ * boundary, never the member's reply: read as one, the room posts it as the+ * bot speaking and loses the failure (#92760). */+export function failedTurnBoundaryRow(row: GroupTranscriptRow): boolean {+ return row.role === 'assistant' && row.display_kind === 'failed_turn'+}+/** A user row that carries no user words: typed scaffolding (auto-continue* notes, steer markers, model-switch notices — anything but a skill* invocation, which is the user's own `/command`) or an untyped row opening@@ -100,7 +109,7 @@ export function externalGroupTranscriptRows(rows: GroupTranscriptRow[]): string[for (const row of rows) {const text = groupTranscriptRowText(row)- if (!text || (row.role !== 'user' && row.role !== 'assistant')) {+ if (!text || (row.role !== 'user' && row.role !== 'assistant') || failedTurnBoundaryRow(row)) {continue}diff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.tsindex af3600f40c9..1292cf4e315 100644--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts@@ -26,6 +26,7 @@ import { vi } from 'vitest'/** One message in a scripted session transcript, in the gateway's own shape. */export interface ScriptedMessage {content: string+ display_kind?: stringrole: string}diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.test.tsindex bd979d29a46..3069a3c4ccb 100644--- a/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts@@ -333,6 +333,41 @@ describe('session-gone classification', () => {}})+ // The core loop closes a failed turn with a Hermes-authored assistant row+ // typed `display_kind: failed_turn` (agent/turn_failure_copy.py). That row is+ // a transcript boundary, not the member speaking: read as the reply, the+ // room posted it as the bot's answer, re-drove the member and hid the error.+ it('reports a failed turn whose transcript Hermes closed with the failed-turn notice', async () => {+ let now = 1_000_000+ const clock = vi.spyOn(Date, 'now').mockImplementation(() => (now += 60_000))++ const room = await loadRoom({+ turn: () => [{ content: 'Your request was not processed.', display_kind: 'failed_turn', role: 'assistant' }]+ })++ const request = host.request as (method: string, params?: Record<string, unknown>) => Promise<unknown>+ let submitted = false++ // The real gateway keeps the tombstone AND the closed transcript.+ host.request = async (method: string, params: Record<string, unknown> = {}) => {+ const result = (await request(method, params)) as Record<string, unknown>++ submitted = submitted || method === 'prompt.submit'++ return method === 'session.resume' && submitted+ ? { ...result, inflight: { error: 'HTTP 401: invalid_api_key', status: 'error', streaming: false } }+ : result+ }++ try {+ await expect(room.turns.runGroupChatMemberTurn('Room', LOCAL_MEMBER, 'hi', 't1', [])).rejects.toThrow(+ 'HTTP 401: invalid_api_key'+ )+ } finally {+ clock.mockRestore()+ }+ })+// A turn that dies BEFORE its prompt is committed (agent-init failure,// no-agent refusal) leaves a retained `{ status: 'error' }` and a transcript// that never grew — the failure must still surface instead of the polldiff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.tsindex 362b40880a0..97bed58b41b 100644--- a/apps/desktop/src/plugins/hermes-bots/group-turns.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.ts@@ -12,7 +12,12 @@ import { noteBotAttention } from './data'import { groupFailureReason, recordGroupActivity } from './group-activity'import { $groupChats, $groupClarify, appendGroupChatEntry, updateGroupChat } from './group-chat'import type { GroupChatRoom } from './group-chat'-import { groupTranscriptRowText, mirrorExternalGroupWrites, syntheticGroupUserRow } from './group-external-writes'+import {+ failedTurnBoundaryRow,+ groupTranscriptRowText,+ mirrorExternalGroupWrites,+ syntheticGroupUserRow+} from './group-external-writes'import {followGroupChat,groupMemberAuthor,@@ -41,6 +46,7 @@ export function isGroupPassText(text: unknown) {* `content` is a plain string on most providers and a part array on the rest. */interface GroupTurnTranscriptMessage {content?: string | Array<string | { text?: string }>+ display_kind?: stringrole?: stringtext?: string}@@ -72,6 +78,10 @@ function pickGroupTurnReply(messages: GroupTurnTranscriptMessage[], before: numbconst replyText = String(text).trim()+ if (failedTurnBoundaryRow(msg)) {+ continue+ }+if (isGroupPassText(replyText)) {if (passText === null) {passText = replyText@@ -112,7 +122,7 @@ function pickStrandedGroupTurnReply(messages: GroupTurnTranscriptMessage[], befobreak}- if (msg?.role !== 'assistant' || !text) {+ if (msg?.role !== 'assistant' || !text || failedTurnBoundaryRow(msg)) {continue}