A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep a failed state write at the end of a part switch from stopping the host
Fei2411c2831a3713c1
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.jsindex e31fb7bc..0c767f42 100644--- a/ds-bot/src/host/parts.js+++ b/ds-bot/src/host/parts.js@@ -787,6 +787,9 @@ export function install(rt) {})await rt.save()})+ // A state write that fails here (full disk, a file another program holds, a lost lock)+ // must not end up as an unhandled rejection, which stops the whole host.+ .catch(error => rt.warn('ds-bot: the switch of %s did not finish: %s', agent.id, error))}async function runSwitch(agent, job) {diff --git a/ds-bot/test/switch-keeps-input.test.js b/ds-bot/test/switch-keeps-input.test.jsindex 92e6ae91..1dff409d 100644--- a/ds-bot/test/switch-keeps-input.test.js+++ b/ds-bot/test/switch-keeps-input.test.js@@ -332,8 +332,8 @@ test('a marked part that stayed current is woken for its kept input, once, in ortest('unmarked earlier parts are never resolved by the restart pass', async (t) => {const host = await start({ services })await moveWriter(host, [])- await until(() => host.state().bots.b.sessionId === 's1')- assert.deepEqual(host.state().switching, {})+ // The fresh part is the Bot's before the switch ends and drops its mark.+ await until(() => host.state().bots.b.sessionId === 's1' && Object.keys(host.state().switching).length === 0)await host.stop({ keep: true })const second = await start({ home: host.home, services })@@ -341,3 +341,21 @@ test('unmarked earlier parts are never resolved by the restart pass', async (t)await second.rt.heldBack()assert.equal(second.resolved.includes('b'), false)})++test('a state write that fails as a switch ends is warned about, not left unhandled', async (t) => {+ const unhandled = []+ const note = (error) => { unhandled.push(error) }+ process.on('unhandledRejection', note)+ t.after(() => { process.off('unhandledRejection', note) })+ const host = await start({ services })+ t.after(host.stop)+ // The write that drops the switch's mark fails, as on a full disk.+ const save = host.rt.save+ host.rt.save = () => (host.rt.state.bots.b.sessionId === 's1' && Object.keys(host.rt.state.switching).length === 0+ ? Promise.reject(new Error('disk full'))+ : save())+ await moveWriter(host, [])+ await until(() => host.warnings.some(line => line.includes('did not finish') && line.includes('disk full')))+ await settle()+ assert.deepEqual(unhandled, [])+})