Skip to content

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

Fix three timing-dependent test failures that CI hit

Fei241115c8a522f19e
diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.js
index 2b68ff81..dbe175a4 100644
--- a/ds-bot/test/roster.test.js
+++ b/ds-bot/test/roster.test.js
@@ -67,6 +67,15 @@ function start(team, { models = [], reasoning = {}, archiveError } = {}) {
}
const settle = () => new Promise(resolve => setTimeout(resolve, 20))
+// A greeting goes out after the team is saved, which can take longer than one settle() on a
+// busy machine.
+const until = async (check) => {
+ const end = Date.now() + 2000
+ while (!check()) {
+ if (Date.now() > end) throw new Error('until: the condition did not hold within 2 s')
+ await settle()
+ }
+}
test('the first Main Bot waits for the user to pick a model, then greets', async (t) => {
const { call, stop, sent, selected } = start(undefined, { models: ['deepseek-v4-flash', 'deepseek-v4-pro'] })
@@ -104,6 +113,7 @@ test('other Bots start on the default model and greet at once', async (t) => {
t.after(stop)
await call('state', {})
const writer = (await call('create-bot', { name: 'Writer' })).value
+ await until(() => sent.length > 0)
await settle()
assert.equal(writer.model, 'deepseek/deepseek-v4-flash')
assert.deepEqual(sent.map(entry => entry.sessionId), [writer.id])
@@ -114,7 +124,7 @@ test('a group the user makes without a first message opens with its admin asking
t.after(stop)
const chief = (await call('state', {})).value.mainBotId
const writer = (await call('create-bot', { name: 'Writer' })).value
- await settle()
+ await until(() => sent.some(entry => entry.sessionId === writer.id))
sent.length = 0
await call('create-room', { members: [chief, writer.id], admin: writer.id })
assert.equal(sent.length, 0)
diff --git a/ds-bot/web-search.js b/ds-bot/web-search.js
index b99041f1..9565cc83 100644
--- a/ds-bot/web-search.js
+++ b/ds-bot/web-search.js
@@ -575,7 +575,7 @@ export function createAutoSearchProvider(deps, config = {}) {
text = await response.text()
} catch (error) {
if (signal?.aborted) throw aborted(signal)
- return { reason: timeout.signal.aborted ? `timed out after ${seconds(budget)}` : `request failed: ${reasonOf(error)}` }
+ return timeout.signal.aborted ? { reason: `timed out after ${seconds(budget)}`, timedOut: true } : { reason: `request failed: ${reasonOf(error)}` }
} finally {
clearTimeout(timer)
}
@@ -604,7 +604,7 @@ export function createAutoSearchProvider(deps, config = {}) {
const keyOf = candidate => [route.provider, candidate.url, candidate.model ?? ''].join('\n')
const works = candidate => memory.get(keyOf(candidate))?.works === true
const ordered = [...plan.candidates.filter(works), ...plan.candidates.filter(candidate => !works(candidate))]
- const deadline = now() + options.nativeTimeoutMs
+ let deadline = now() + options.nativeTimeoutMs
const notes = []
let credential
for (const candidate of ordered) {
@@ -633,6 +633,9 @@ export function createAutoSearchProvider(deps, config = {}) {
notes.push(`${where}: ${outcome.reason}`)
if (outcome.skip !== undefined) memory.set(keyOf(candidate), { until: now() + SKIP_FOR[outcome.skip], reason: outcome.reason })
if (outcome.final) break
+ // A timed-out attempt had all the time that was left, but the timer and now() use
+ // different clocks, so now() can still read a millisecond before the deadline.
+ if (outcome.timedOut) deadline = now()
}
return { reason: `route "${route.provider}": ${notes.join('; ')}` }
}