Skip to content

The agent that grows with you

fix(bots): label cap-forced drive exits distinctly from consensus settle (#94478)

Teknium1ae2c2b17156
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index 2b84b4a046a..bd00ddb03cc 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -494,7 +494,7 @@ function groupActivityLabel(event) {
const kind = event?.kind
const base = GROUP_ACTIVITY_LABELS[kind] || kind || 'did something'
- if (kind === 'cancelled' || kind === 'settled') {
+ if (kind === 'cancelled' || kind === 'settled' || kind === 'capped') {
return base
}
@@ -512,6 +512,7 @@ const GROUP_ACTIVITY_LABELS = {
failed: 'hit an error',
cancelled: 'turn interrupted by a newer message',
settled: 'turn settled',
+ capped: 'turn stopped at the round/message cap',
delivered: 'delivered a late reply',
held: 'is held (stopped by you) — @mention it or say resume to release'
}
@@ -525,6 +526,7 @@ const GROUP_ACTIVITY_GLYPHS = {
failed: 'error',
cancelled: 'close',
settled: 'check-all',
+ capped: 'debug-step-over',
delivered: 'mail-read',
held: 'debug-pause'
}
@@ -8059,6 +8061,10 @@ async function runGroupChatRounds(group, members, thread) {
const isCurrent = () => (($groupChats.get()[group] || {}).epoch || 0) === startEpoch
let posted = 0
let continuations = 0
+ // #94478: how this drive ended. 'settled' means quiet consensus (everyone
+ // passed with nothing pending); 'capped' means a round/message/continuation
+ // cap forced the exit — the activity feed must tell those apart.
+ let exitKind = 'settled'
try {
for (let round = 0; round < GROUP_CHAT_MAX_ROUNDS; round++) {
@@ -8096,6 +8102,8 @@ async function runGroupChatRounds(group, members, thread) {
if (!isCurrent() || posted >= GROUP_CHAT_MAX_MESSAGES) {
if (!isCurrent()) {
recordGroupActivity(group, { kind: 'cancelled', member: null, thread })
+ } else {
+ exitKind = 'capped' // message cap, not consensus (#94478)
}
return
}
@@ -8348,14 +8356,24 @@ async function runGroupChatRounds(group, members, thread) {
if (spokeThisRound === 0) {
// Genuinely nothing left to say — including after the continuation
- // attempt above produced no spoken turns. Settle honestly.
+ // attempt above produced no spoken turns. Settle honestly, but if
+ // cited members are STILL owed a turn and only the continuation /
+ // message caps stopped us from driving them, this is a capped
+ // exit, not consensus. (#94478)
+ if (pendingKeys.length && (continuations > GROUP_CHAT_MAX_CONTINUATIONS || posted >= GROUP_CHAT_MAX_MESSAGES)) {
+ exitKind = 'capped'
+ }
return
}
}
}
+
+ // All GROUP_CHAT_MAX_ROUNDS rounds ran with someone still speaking —
+ // the round cap ended the drive, not consensus. (#94478)
+ exitKind = 'capped'
} finally {
if (isCurrent()) {
- recordGroupActivity(group, { kind: 'settled', member: null, thread })
+ recordGroupActivity(group, { kind: exitKind, member: null, thread })
updateGroupChat(group, r => {
r.running = false
r.turn = null
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/94478-mention-settle.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/94478-mention-settle.test.mjs
index 0dfcfb9a976..827a2d6c04e 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/94478-mention-settle.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/94478-mention-settle.test.mjs
@@ -83,3 +83,44 @@ test('#94478: does not flag a handoff the cited member already answered', () =>
assert.ok(answerIdx > mentionIdx, 'answer must postdate the mention')
})
+
+// --- exit-path wiring contracts (salvage follow-up) -------------------------
+// The two tests above pin the detector's semantics in isolation; these pin the
+// WIRING — the quiet-round exit must consult the detector before settling, and
+// a cap-forced exit must be labelled distinctly from consensus settle.
+import { readFileSync } from 'node:fs'
+
+const pluginSource = readFileSync(new URL('../plugin.js', import.meta.url), 'utf8')
+
+test('#94478: the quiet-round exit consults unaddressedGroupMentions before settling', () => {
+ const loopStart = pluginSource.indexOf('async function runGroupChatRounds')
+ assert.ok(loopStart >= 0, 'runGroupChatRounds must exist')
+
+ const loop = pluginSource.slice(loopStart, pluginSource.indexOf('\n}', loopStart) + 2)
+
+ // The spokeThisRound === 0 path may no longer settle unconditionally: it
+ // must call the detector and drive a bounded continuation round first.
+ assert.ok(
+ loop.includes('unaddressedGroupMentions(group, members, thread)'),
+ 'quiet-round exit must check for unanswered @mention handoffs before settling'
+ )
+ assert.ok(
+ loop.includes('GROUP_CHAT_MAX_CONTINUATIONS'),
+ 'continuation rounds must be bounded by GROUP_CHAT_MAX_CONTINUATIONS'
+ )
+})
+
+test('#94478: a cap-forced exit is labelled distinctly from consensus settle', () => {
+ const loopStart = pluginSource.indexOf('async function runGroupChatRounds')
+ const loop = pluginSource.slice(loopStart, pluginSource.indexOf('\n}', loopStart) + 2)
+
+ // The finally must record the tracked exit kind, not a hardcoded 'settled'.
+ assert.ok(
+ /recordGroupActivity\(group, \{ kind: exitKind, member: null, thread \}\)/.test(loop),
+ 'the drive-end activity entry must use the tracked exit kind'
+ )
+ assert.ok(/exitKind = 'capped'/.test(loop), 'cap exits must set the capped exit kind')
+
+ // And the activity vocabulary must know the new kind.
+ assert.ok(/\bcapped:\s*'/.test(pluginSource), "GROUP_ACTIVITY_LABELS must define 'capped'")
+})