Skip to content

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

Show a question card asked in a hidden Bot-to-Bot turn

FeiZhuLulu7ac62be47803
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index 732a049b..5561a18f 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -354,9 +354,13 @@ export function install(rt) {
.filter(option => option.label !== '')
.slice(0, 6)
if (options.length === 0) return 'Give at least one option.'
+ // A hidden Bot-to-Bot turn shows none of its calls, so its card goes to the
+ // composer dock, which takes questions without a call.
+ const turn = rt.live.get(id)?.turn
+ const hidden = turn !== undefined && (state.exchangeTurns[id] ?? []).includes(turn)
state.questions[id] = {
id: randomUUID(),
- ...(exec.callId ? { callId: exec.callId } : {}),
+ ...(exec.callId && !hidden ? { callId: exec.callId } : {}),
question: String(args.question ?? '').trim(),
...(args.detail ? { detail: String(args.detail).trim() } : {}),
options,
diff --git a/ds-bot/test/questions.test.js b/ds-bot/test/questions.test.js
new file mode 100644
index 00000000..9e5961cc
--- /dev/null
+++ b/ds-bot/test/questions.test.js
@@ -0,0 +1,87 @@
+import assert from 'node:assert/strict'
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { test } from 'node:test'
+import { apply } from '../index.js'
+import { fakeContext } from './fake-ctx.js'
+
+const TEAM = {
+ version: 1,
+ mainBotIds: ['chief'],
+ bots: {
+ chief: { id: 'chief', name: 'Chief', role: 'Lead', sessionId: 'chief', createdAt: 1 },
+ writer: { id: 'writer', name: 'Writer', role: 'Write', sessionId: 'writer', createdAt: 2 },
+ },
+ rooms: {},
+ agents: {},
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+ prefs: {},
+ revision: 0,
+}
+
+async function start() {
+ const home = mkdtempSync(join(tmpdir(), 'ds-bot-questions-'))
+ writeFileSync(join(home, 'state.json'), JSON.stringify(TEAM))
+ const ctx = fakeContext()
+ Object.assign(ctx, {
+ workspaceRegistry: { get: () => undefined, resolveByPath: async () => undefined, create: async path => ({ id: 'w1', path }), archiveSession: async () => {} },
+ sessionController: { create: async () => ({ sessionId: 's1' }), resolveAgent: async sessionId => ({ agent: { session: { id: sessionId }, followup() {} } }), selectModel: async () => {} },
+ sessionTitle: { rename: async () => {} },
+ sessions: { flush: async () => {} },
+ })
+ let route
+ const register = ctx.connection.fetch.register
+ ctx.connection.fetch.register = (options) => {
+ route = options
+ return register(options)
+ }
+ apply(ctx, { home })
+ let seq = 0
+ const emit = (id, type, data) => {
+ for (const listener of ctx.listeners.get('session/event') ?? []) {
+ if (listener.length >= 2) listener({ id }, { type, seq: ++seq, data })
+ }
+ }
+ const ask = (sessionId, callId) => ctx.registeredTools.get('ask_user').execute(
+ { question: 'Which name?', options: [{ label: 'Lookout' }, { label: 'Scout' }] },
+ { agent: { id: sessionId }, callId, concludeTurn() {} },
+ )
+ const questions = async () => (await (await route.fetch(new Request('http://localhost/api/bot', {
+ method: 'POST', body: JSON.stringify({ endpoint: 'state', payload: {} }),
+ }))).json()).value.questions
+ // Loading once fills the Session-owner indexes turns.js filters events by.
+ await ctx.registeredTools.get('list_bots').execute({}, { agent: { id: 'chief' } })
+ return { emit, ask, questions, stop: () => { ctx.dispose(); rmSync(home, { recursive: true, force: true }) } }
+}
+
+const text = value => [{ type: 'text', text: value }]
+
+test('a card asked in a hidden Bot-to-Bot turn goes to the dock, without its call', async (t) => {
+ const { emit, ask, questions, stop } = await start()
+ t.after(stop)
+ emit('writer', 'turn/start', { turn: 1 })
+ emit('writer', 'user/message', { content: text('[Message from Chief]\nThe user wants a new Bot; ask them for its name'), source: { kind: 'bot', role: 'request', senderSessionId: 'chief', senderName: 'Chief', exchangeId: 'x1', hop: 0 } })
+ await ask('writer', 'call-1')
+ const asked = (await questions()).writer
+ assert.equal(asked.question, 'Which name?')
+ assert.equal(asked.callId, undefined)
+})
+
+test('a card asked in a visible turn stays at its call', async (t) => {
+ const { emit, ask, questions, stop } = await start()
+ t.after(stop)
+ emit('writer', 'turn/start', { turn: 1 })
+ emit('writer', 'user/message', { content: text('Help me name a Bot'), source: { kind: 'user' } })
+ await ask('writer', 'call-2')
+ assert.equal((await questions()).writer.callId, 'call-2')
+
+ // A message that asks for an answer in the recipient's own chat is visible too.
+ emit('writer', 'turn/end', { turn: 1, reason: { kind: 'completed' } })
+ emit('writer', 'turn/start', { turn: 2 })
+ emit('writer', 'user/message', { content: text('[Message from Chief · the user sees your reply here]\nIntroduce yourself'), source: { kind: 'bot', role: 'request', audience: 'user', senderSessionId: 'chief', senderName: 'Chief', exchangeId: 'x2', hop: 0 } })
+ await ask('writer', 'call-3')
+ assert.equal((await questions()).writer.callId, 'call-3')
+})