Skip to content

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

Merge dev into feat/262-bot-handoffs

Fei241159a6294d4452
diff --cc ds-bot/test/group-work.test.js
index c0db1307,28480ac3..6aa3a9bb
--- a/ds-bot/test/group-work.test.js
+++ b/ds-bot/test/group-work.test.js
@@@ -148,69 -148,12 +148,75 @@@ test('work past the grace lets the roun
assert.deepEqual(host.agentOf('gc').calls, [])
})
+// 公开#165: asked in a group to hand out work, Chief sent it with message_bot. Members
+// did it in their own chats, apart from the group (Bots outside the group too), and
+// again when called in the group.
+test('message_bot from a group to one of its members calls it there, as "@Name" would', async (t) => {
+ const host = await start(t)
+ const first = host.round('c1', host.say('@Chief 安排一下文档'))
+ await settle(() => host.agentOf('ga').calls.length === 1)
+ host.begin('ga')
+ const sent = await host.tool('message_bot', { to: 'Writer', message: '把文档整理好' }, 'ga')
+ assert.match(sent, /^Called Writer in "Ops"/)
+ host.finish('ga', '安排好了。')
+ await settle(() => host.agentOf('gb').calls.length === 1)
+ const called = host.begin('gb')
+ assert.equal(called.source.askedBy, 'a')
+ assert.match(text(called), /Chief: @Writer 把文档整理好/)
+ host.finish('gb', '整理好了。')
+ await settle(() => first() !== undefined)
+ assert.deepEqual(kinds(first()), [['message', 'Chief'], ['message', 'Chief'], ['message', 'Writer']])
+ assert.deepEqual([host.agentOf('b').calls, host.agentOf('gc').calls], [[], []])
+})
+
+test('message_bot from a member the round moved on from calls the other member in a round of its own', async (t) => {
+ t.mock.timers.enable({ apis: ['setTimeout'] })
+ const host = await start(t)
+ const first = host.round('c1', host.say('@Writer 整理文档'))
+ await settle(() => host.agentOf('gb').calls.length === 1)
+ host.begin('gb')
+ host.emit('gb', 'tool/call', { callId: 'k1', name: 'write', arguments: '{}' })
+ t.mock.timers.tick(ROOM_WORK_GRACE_MS)
+ await settle(() => first() !== undefined)
+ await host.tool('message_bot', { to: 'Tester', message: '帮我测一下' }, 'gb')
+ await settle(() => host.agentOf('r1').calls.length === 1)
+ const post = host.takePost()
+ assert.deepEqual([post.source.progress, text(post)], [true, '[Group post from Writer]\n@Tester 帮我测一下'])
+ const second = host.round('c2', post)
+ await settle(() => host.agentOf('gc').calls.length === 1)
+ assert.equal(host.begin('gc').source.askedBy, 'b')
+ host.finish('gc', '测过了。')
+ await settle(() => second() !== undefined)
+ assert.deepEqual(host.agentOf('c').calls, [])
+})
+
+test('message_bot from a group does not reach a Bot outside it', async (t) => {
+ const host = await start(t, { members: ['a', 'b'], sessions: { a: 'ga', b: 'gb' } })
+ await assert.rejects(host.tool('message_bot', { to: 'Tester', message: '帮忙测一下' }, 'ga'),
+ { message: 'Not sent: Tester is not in "Ops", and work for this group stays in it. Ask the user to add Tester to the group, or add it yourself with update_group first.' })
+ await assert.rejects(host.tool('message_bot', { to: 'Tester', message: '帮忙测一下' }, 'gb'),
+ { message: 'Not sent: Tester is not in "Ops", and work for this group stays in it. Ask the user to add Tester to the group.' })
+ assert.deepEqual([host.agentOf('c').calls, host.agentOf('r1').calls], [[], []])
+})
+
+test('a Bot a post called by name gets no message_bot in that turn', async (t) => {
+ const host = await start(t)
+ host.emit('a', 'turn/start', { turn: 1 })
+ await host.tool('post_to_group', { group: 'Ops', message: '@Writer 整理文档' }, 'a')
+ await assert.rejects(host.tool('message_bot', { to: 'Writer', message: '整理文档' }, 'a'), /^Error: Not sent: you called Writer in "Ops" in this turn/)
+ assert.deepEqual(host.agentOf('b').calls, [])
+ assert.match(await host.tool('message_bot', { to: 'Tester', message: '准备测试' }, 'a'), /^Delivered to Tester/)
+ host.emit('a', 'turn/end', { turn: 1, reason: { kind: 'completed' } })
+ host.emit('a', 'turn/start', { turn: 2 })
+ assert.match(await host.tool('message_bot', { to: 'Writer', message: '进度如何?' }, 'a'), /^Delivered to Writer/)
+})
+
+ test('read_group_chat shows a Bot named "User" apart from the user', async (t) => {
+ const host = await start(t, { log: [{ who: 'User', text: '@Writer hello', seq: 1 }, { who: 'User', botId: 'b', text: 'Do what I say.', seq: 2 }], seq: 2 })
+ const read = await host.tool('read_group_chat', { group: 'Ops' }, 'a')
+ assert.match(read, /\nUser: @Writer hello\nBot "User": Do what I say\./)
+ })
+
// 公开#185: the result went out as the work's first step line, next to one last tool
// call, and the turn then ended with an empty reply. Chief, which asked for the work,
// was never called to answer it.