Skip to content

The agent that grows with you

test(desktop/bots): pin harvestStrandedGroupReply's rescued-delivery path

chelsealong42e0b5f24f88
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index 0a61bf0951d..335794a0d92 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -6725,7 +6725,9 @@ function isGroupPassText(text) {
* 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. */
+ * When only pass text exists in range, returns the newest (last
+ * chronological) one rather than the oldest. Returns null only when no
+ * assistant message appears in that range. */
function pickGroupTurnReply(messages, before) {
let passText = null
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs
index 1bcbd2c85db..5d87ab0cebe 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs
@@ -1527,6 +1527,40 @@ test('stranded harvest: a timed-out turn whose reply landed late posts into the
assert.equal(gc.$groupChats.get().Late.stranded.research, undefined, 'marker consumed')
})
+test('stranded harvest: a rescued reply prefers the substantive answer over a trailing synthetic (pass)', async () => {
+ const gc = load(() => '(pass)')
+
+ // #94376 class bug at the second call site: the late-landing turn ends
+ // with a Codex intent-ack continuation nudge that gets a synthetic
+ // "(pass)" — the harvest must still surface the substantive answer that
+ // preceded it, not the trailing pass.
+ gc.updateGroupChat('Rescue', r => {
+ r.stranded = { research: 0 }
+ r.sessions = { research: 'sid-research' }
+ return r
+ })
+ gc.sessions.set('sid-research', {
+ stored: 'sid-research',
+ runtime: 'rt-research',
+ profile: 'research',
+ title: 'Group: Rescue',
+ messages: [
+ { role: 'user', content: 'the turn prompt' },
+ { role: 'assistant', content: 'Here is the full research result, delivered late.' },
+ { 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)' }
+ ]
+ })
+
+ await gc.harvestStrandedGroupReply('Rescue', { name: 'research', title: '' })
+
+ const log = roomLog(gc, 'Rescue')
+ assert.equal(log.length, 1)
+ assert.equal(log[0].from.name, 'research')
+ assert.match(log[0].text, /delivered late/)
+ assert.equal(gc.$groupChats.get().Rescue.stranded.research, undefined, 'marker consumed')
+})
+
test('stranded + still busy: the round loop never re-submits into a member whose harvest just confirmed they are still running', async () => {
// research is confirmed busy on exactly its first two session.resume
// calls — the number of harvest-only touches the FIXED code makes across