Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Fail a member's round call when its turn fails before taking it

Fei2411ffac47f0556b
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.js
index 9f636fd5..6dc0df60 100644
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@ -254,6 +254,11 @@ export function install(rt) {
|| (owner !== undefined && waiter.botId === owner.botId && waiter.roomId === owner.roomId))
}
rt.touchRoomTurn = (sessionId) => { for (const waiter of waitersOf(sessionId)) waiter.touch() }
+ rt.failRoomTurn = (sessionId, failure) => {
+ const waiters = waitersOf(sessionId)
+ for (const waiter of waiters) waiter.fail(failure)
+ return waiters.length > 0
+ }
rt.yieldRoomTurn = (sessionId) => { for (const waiter of waitersOf(sessionId)) waiter.approval() }
// The team's own tools are quick; any other tool is the start of work.
const QUICK_TOOLS = new Set(TEAM_TOOLS)
diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.js
index ba4bd434..d3dafc17 100644
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@ -522,7 +522,10 @@ export function install(rt) {
else void rt.lateRoomReply?.(id, info, groupReply())
}
} else if (!retry && speaksInGroup(id, info)) {
- if (failure !== undefined) void rt.lateRoomFailure?.(id, info ?? {}, failure)
+ // A turn that failed before it took any input (DSH can turn it down before its
+ // first step) never names its call, so the call waiting on this Session fails.
+ const inRound = failure !== undefined && info === undefined && rt.failRoomTurn?.(id, failure) === true
+ if (failure !== undefined) { if (!inRound) void rt.lateRoomFailure?.(id, info ?? {}, failure) }
else if (reason?.kind !== 'aborted') void rt.lateRoomReply?.(id, info ?? {}, groupReply())
} else if (!retry && info !== undefined) {
answer(info, replyText())
diff --git a/ds-bot/test/rounds.test.js b/ds-bot/test/rounds.test.js
index 495826dc..44181c15 100644
--- a/ds-bot/test/rounds.test.js
+++ b/ds-bot/test/rounds.test.js
@@ -347,3 +347,22 @@ test('a message sent between rounds still opens a full round', async (t) => {
const result = JSON.parse(await running)
assert.deepEqual(result.replies.map(reply => reply.name ?? 'User'), ['Chief', 'Writer'])
})
+
+// #209: DSH can fail a member's turn before its first step (DSH 0.2.1 does so for a folder
+// that is gone), so the turn never takes the round's call. The round counts the failure at
+// once instead of waiting minutes for a reply that cannot come.
+test('a member turn that fails before it takes the call fails that member in the round at once', async (t) => {
+ const { call, emit, userMessage, relay, answer, stop, sent } = start()
+ t.after(stop)
+ const room = await team(call, sent)
+ await emit(room.id, userMessage('Start'))
+ const running = relay(room.id, 'relay')
+ const first = await turnFor(sent)
+ await emit(first.sessionId, { type: 'turn/start', data: { turn: 1 } })
+ await emit(first.sessionId, { type: 'turn/end', data: { reason: { kind: 'error', error: { message: 'working-directory: directory does not exist: "/gone"', code: 'UNKNOWN' } } } })
+ const second = await turnFor(sent, first)
+ assert.ok(second, 'the next member speaks without waiting for the reply timeout')
+ await answer(second.sessionId, second.message.source.exchangeId, 'Writer here.', 1)
+ const result = JSON.parse(await running)
+ assert.deepEqual(result.replies.map(reply => [reply.kind ?? 'reply', reply.name]), [['failed', 'Chief'], ['reply', 'Writer']])
+})