Skip to content

The agent that grows with you

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.ts
index 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.ts
index 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?: string
role: string
}
diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.test.ts
index 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 poll
diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.ts
index 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?: string
role?: string
text?: string
}
@@ -72,6 +78,10 @@ function pickGroupTurnReply(messages: GroupTurnTranscriptMessage[], before: numb
const replyText = String(text).trim()
+ if (failedTurnBoundaryRow(msg)) {
+ continue
+ }
+
if (isGroupPassText(replyText)) {
if (passText === null) {
passText = replyText
@@ -112,7 +122,7 @@ function pickStrandedGroupTurnReply(messages: GroupTurnTranscriptMessage[], befo
break
}
- if (msg?.role !== 'assistant' || !text) {
+ if (msg?.role !== 'assistant' || !text || failedTurnBoundaryRow(msg)) {
continue
}