Skip to content

The agent that grows with you

fix(desktop/bots): keep a substantive group reply after a synthetic (pass)

chelsealong8d412e67ba70
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index b15bf442ee0..0a61bf0951d 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -6720,6 +6720,42 @@ function isGroupPassText(text) {
return /^\(?\s*pass\s*\)?\.?$/i.test(trimmed)
}
+/** #94376: pick the reply a finished turn should surface among the messages
+ * appended since `before`. Scans newest-first and prefers the last
+ * substantive (non-pass) assistant answer over a trailing pass — a Codex
+ * intent-ack continuation nudge can land a complete answer and then get a
+ * synthetic "(pass)" to the nudge itself, which must not hide the answer.
+ * Returns null only when no assistant message appears in that range. */
+function pickGroupTurnReply(messages, before) {
+ let passText = null
+
+ for (let i = messages.length - 1; i >= before; i--) {
+ const msg = messages[i]
+
+ if (msg?.role !== 'assistant') {
+ continue
+ }
+
+ const text = typeof msg.content === 'string'
+ ? msg.content
+ : Array.isArray(msg.content)
+ ? msg.content.map(p => (typeof p === 'string' ? p : p?.text || '')).join('')
+ : msg?.text || ''
+ const replyText = String(text).trim()
+
+ if (isGroupPassText(replyText)) {
+ if (passText === null) {
+ passText = replyText
+ }
+ continue
+ }
+
+ return replyText
+ }
+
+ return passText
+}
+
/** Deterministic @mention parse. Handles @name, @"two words" via display
* titles, and @everyone/@all. Names match case-insensitively against member
* profile names, display titles, and collapsed no-space forms. */
@@ -7742,25 +7778,16 @@ async function runGroupChatMemberTurnLeased(group, member, prompt, thread, image
const done = !busy && !awaitingUser
if (messages.length > before && done) {
- for (let i = messages.length - 1; i >= 0; i--) {
- const msg = messages[i]
-
- if (msg?.role === 'assistant') {
- const text = typeof msg.content === 'string'
- ? msg.content
- : Array.isArray(msg.content)
- ? msg.content.map(p => (typeof p === 'string' ? p : p?.text || '')).join('')
- : msg?.text || ''
- const replyText = String(text).trim()
+ const replyText = pickGroupTurnReply(messages, before)
- recordGroupActivity(group, {
- kind: isGroupPassText(replyText) ? 'passed' : 'replied',
- member: member.name,
- thread
- })
+ if (replyText !== null) {
+ recordGroupActivity(group, {
+ kind: isGroupPassText(replyText) ? 'passed' : 'replied',
+ member: member.name,
+ thread
+ })
- return replyText
- }
+ return replyText
}
recordGroupActivity(group, { kind: 'passed', member: member.name, thread })
@@ -7841,33 +7868,20 @@ async function harvestStrandedGroupReply(group, member) {
return
}
- for (let i = messages.length - 1; i >= 0; i--) {
- const msg = messages[i]
+ const reply = pickGroupTurnReply(messages, strandedBefore)
- if (msg?.role === 'assistant') {
- const text = typeof msg.content === 'string'
- ? msg.content
- : Array.isArray(msg.content)
- ? msg.content.map(p => (typeof p === 'string' ? p : p?.text || '')).join('')
- : msg?.text || ''
- const reply = String(text).trim()
-
- if (reply && !isGroupPassText(reply)) {
- recordGroupActivity(group, { kind: 'delivered', member: member.name, thread: strandedThread })
- appendGroupChatEntry(
- group,
- { kind: 'member', name: member.name, ...(member.remoteSource ? { source: member.connectionLabel || member.connectionId } : {}) },
- reply,
- strandedThread
- )
- updateGroupChat(group, r => {
- r.watermarks[`${strandedThread}::${memberKey}`] = r.log.length
- return r
- })
- }
-
- return
- }
+ if (reply && !isGroupPassText(reply)) {
+ recordGroupActivity(group, { kind: 'delivered', member: member.name, thread: strandedThread })
+ appendGroupChatEntry(
+ group,
+ { kind: 'member', name: member.name, ...(member.remoteSource ? { source: member.connectionLabel || member.connectionId } : {}) },
+ reply,
+ strandedThread
+ )
+ updateGroupChat(group, r => {
+ r.watermarks[`${strandedThread}::${memberKey}`] = r.log.length
+ return r
+ })
}
}
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/group-turn-lease.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/group-turn-lease.test.mjs
index 109682ef05e..446611e4f51 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/group-turn-lease.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/group-turn-lease.test.mjs
@@ -18,7 +18,7 @@ const pluginSource = readFileSync(new URL('../plugin.js', import.meta.url), 'utf
/** Harness mirroring group-chat-attachments.test.mjs, extended with a
* refcounted host.requestProfile/host.retainProfile pair so socket lease
* lifetimes are assertable. */
-function load({ failFirstSubmitWith = null, failEverySubmitWith = null, reply = 'hello from turn' } = {}) {
+function load({ failFirstSubmitWith = null, failEverySubmitWith = null, reply = 'hello from turn', replyMessages = null } = {}) {
const values = new Map()
const atom = initial => {
const slot = { get: () => values.get(slot), set: value => values.set(slot, value) }
@@ -114,7 +114,13 @@ function load({ failFirstSubmitWith = null, failEverySubmitWith = null, reply =
throw err
}
session.messages.push({ role: 'user', content: params.text })
- session.messages.push({ role: 'assistant', content: reply })
+ if (replyMessages) {
+ for (const msg of replyMessages) {
+ session.messages.push(msg)
+ }
+ } else {
+ session.messages.push({ role: 'assistant', content: reply })
+ }
return {}
}
return {}
@@ -270,3 +276,28 @@ test('hosts without retainProfile still run the turn (feature detection)', async
assert.equal(reply, 'legacy ok')
})
+
+// #94376: a Codex intent-ack continuation nudge can land a substantive
+// answer, then get a synthetic "(pass)" reply to the nudge itself. The
+// substantive answer must still surface, not the trailing pass.
+test('a substantive answer followed by a synthetic continuation (pass) still surfaces the answer', async () => {
+ const gc = load({
+ replyMessages: [
+ { role: 'assistant', content: "Yes. I welcomed them, and I'll review their first assignments with them." },
+ { role: 'user', content: '[System: Continue now. Execute the required tool calls and only send your final answer after completing the task.]' },
+ { role: 'assistant', content: '(pass)' }
+ ]
+ })
+
+ const reply = await gc.runGroupChatMemberTurn('Room', LOCAL_MEMBER, 'Did you welcome the new teammate?', 't1', [])
+
+ assert.equal(reply, "Yes. I welcomed them, and I'll review their first assignments with them.")
+})
+
+test('a genuine pass-only turn (no prior substantive answer) still reads as silent', async () => {
+ const gc = load({ reply: '(pass)' })
+
+ const reply = await gc.runGroupChatMemberTurn('Room', LOCAL_MEMBER, 'anything new?', 't1', [])
+
+ assert.equal(reply, '(pass)')
+})