Skip to content

The agent that grows with you

fix(desktop): surface pool slot-wait cause in group activity labels

joaomarcos9ae34de7e90a
diff --git a/apps/desktop/src/plugins/hermes-bots/group-activity.ts b/apps/desktop/src/plugins/hermes-bots/group-activity.ts
index 067b8197160..2f6f5d39615 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-activity.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-activity.ts
@@ -69,9 +69,43 @@ export function currentGroupActivity(group: string) {
return ($groupActivity.get()[group] || {}).events?.filter(event => (event.epoch || 0) === epoch) || []
}
+/** Normalized cause for a pool-slot wait timeout — the local backend pool
+ * had no free slot, so the member never started. Stored as the activity
+ * event's `reason` so the feed can tell it apart from a bot crash.
+ * The string deliberately contains "timeout": `attentionReasonFromError`
+ * must keep classifying it as transient (never a roster badge). */
+export const GROUP_SLOT_WAIT_REASON = 'slot_wait_timeout'
+
+/** Stable coordinator phrase (`pool-spawn-coordinator.ts`), the
+ * cross-process discriminator — same shape as `isLocalBackendSlotWaitTimeout`
+ * in `store/pool-limits.ts`, kept local because the plugin fence cannot
+ * import the store. Match narrowly so other backend failures keep their path. */
+export function isGroupSlotWaitTimeoutText(text: unknown): boolean {
+ return typeof text === 'string' && text.includes('timed out while waiting for a free slot')
+}
+
+/** Typed failure cause for a member-turn error: the gateway's
+ * `data.reason` when present, else the normalized slot-wait cause when the
+ * message carries the coordinator phrase, else ''. Single home for the
+ * classification so the turn catch and the stranded harvest cannot drift. */
+export function groupFailureReason(error: unknown): string {
+ const typed = typeof (error as { data?: { reason?: unknown } })?.data?.reason === 'string'
+ ? String((error as { data: { reason: string } }).data.reason).trim()
+ : ''
+
+ if (typed) {
+ return typed
+ }
+
+ const message = error instanceof Error ? error.message : typeof error === 'string' ? error : ''
+
+ return isGroupSlotWaitTimeoutText(message) ? GROUP_SLOT_WAIT_REASON : ''
+}
+
/** Human label for one activity event, used by the collapsed summary and
* the expanded rows. `group` scopes the same-name disambiguation to the
- * room's seats. */
+ * room's seats. A slot-wait failure renders distinctly from a bot crash so
+ * pool saturation is not misread as a broken bot. */
export function groupActivityLabel(event: GroupActivityEntry, group?: null | string) {
const kind = event?.kind
const base = GROUP_ACTIVITY_LABELS[kind] || kind || 'did something'
@@ -83,6 +117,10 @@ export function groupActivityLabel(event: GroupActivityEntry, group?: null | str
const who = event?.member === 'You' ? 'You' : groupSpeakerLabel(event?.member || 'A bot', group)
const reason = kind === 'failed' ? String(event?.reason || '').trim() : ''
+ if (kind === 'failed' && reason === GROUP_SLOT_WAIT_REASON) {
+ return `${who} couldn't start — too many bots running`
+ }
+
return `${who} ${base}${reason ? ` — ${reason}` : ''}`
}
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 2292f18fe5d..6c9ebd4820b 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
@@ -1,5 +1,5 @@
import { clearBotAttention, noteBotAttention } from './data'
-import { recordGroupActivity } from './group-activity'
+import { groupFailureReason, recordGroupActivity } from './group-activity'
import {
$groupChats,
appendGroupChatEntry,
@@ -161,7 +161,7 @@ export async function runGroupRoundMember(
return null
}
- const reason = String(error?.data?.reason || '').trim()
+ const reason = groupFailureReason(error)
recordGroupActivity(context.group, {
kind: 'failed',
member: groupMemberKey(member),
diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.ts
index c63d98a3462..2bd5ff26c93 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-turns.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.ts
@@ -9,7 +9,7 @@
import { host } from '@hermes/plugin-sdk'
import { noteBotAttention } from './data'
-import { recordGroupActivity } from './group-activity'
+import { groupFailureReason, recordGroupActivity } from './group-activity'
import { $groupChats, $groupClarify, appendGroupChatEntry, updateGroupChat } from './group-chat'
import type { GroupChatRoom } from './group-chat'
import {
@@ -1244,12 +1244,14 @@ export async function harvestStrandedGroupReply(group: string, member: GroupMemb
const failure = retainedGroupTurnError(state)
if (failure !== null) {
+ const reason = groupFailureReason(failure)
recordGroupActivity(group, {
kind: 'failed',
member: memberKey,
- thread: strandedThread
+ thread: strandedThread,
+ ...(reason ? { reason } : {})
})
- noteBotAttention(memberKey, failure)
+ noteBotAttention(memberKey, reason || failure)
}
}
diff --git a/apps/desktop/src/plugins/hermes-bots/types.ts b/apps/desktop/src/plugins/hermes-bots/types.ts
index a14896dcfa5..e952b53ff36 100644
--- a/apps/desktop/src/plugins/hermes-bots/types.ts
+++ b/apps/desktop/src/plugins/hermes-bots/types.ts
@@ -278,6 +278,8 @@ export interface GroupActivityEvent {
kind: GroupActivityKind
member?: string
preview?: string
+ /** Typed failure cause (gateway `data.reason` or the normalized
+ * `slot_wait_timeout`); absent on non-failures and untyped failures. */
reason?: string
}