Skip to content

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

Keep DeepSeek Harness's blocking question tool out of Bot Sessions

Fei2411851688b96862
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cfd3e1c6..92589e2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
### Fixed
- A new Bot asks where to start in its first reply instead of on a question card, and follows its own instructions where they say otherwise.
+- Bots no longer use DeepSeek Harness's own question card, which held the Bot until you answered it while messages from other Bots waited.
## [0.1.4] - 2026-10-13
diff --git a/ds-bot/dev/smoke.mjs b/ds-bot/dev/smoke.mjs
index cab38529..57527d99 100644
--- a/ds-bot/dev/smoke.mjs
+++ b/ds-bot/dev/smoke.mjs
@@ -190,6 +190,13 @@ await step('Chief creates Writer, who replies', () => send(chief().id, '创建
?? expect(kinds.includes('request') && kinds.includes('reply'), `expected a request and a reply, got ${kinds}`)
})
+// The mock calls dsh's ask_user_question for 阻塞提问 whenever the request offers it.
+await step('a Bot is not offered dsh\'s blocking question tool', () => send(botNamed('Writer').id, '阻塞提问'), (_value, calls) => {
+ const asked = calls.some(call => (call.out ?? []).some(block => block.type === 'tool_use' && block.name === 'ask_user_question'))
+ return expect(!asked, 'Writer called ask_user_question')
+ ?? expect(saidText(calls, /^收到:阻塞提问/), 'expected Writer to answer in its reply')
+})
+
await step('user creates Coder, who keeps the default model', () => api('create-bot', { name: 'Coder', role: 'Engineer', instructions: 'Write code.' }), (bot) => {
const coder = botNamed('Coder')
return expect(coder && coder.id === bot.id && coder.role === 'Engineer', 'Coder not saved as asked')
diff --git a/ds-bot/src/host/delivery.js b/ds-bot/src/host/delivery.js
index ad62cb85..ae2e8157 100644
--- a/ds-bot/src/host/delivery.js
+++ b/ds-bot/src/host/delivery.js
@@ -9,6 +9,7 @@ export function install(rt) {
const resolveAgent = async (sessionId) => {
const resolved = await ctx.sessionController.resolveAgent(sessionId)
if ('error' in resolved) throw new Error(resolved.error?.message ?? 'Session unavailable')
+ rt.hideBlockingQuestion(resolved.agent)
return resolved.agent
}
diff --git a/ds-bot/src/host/prompt.js b/ds-bot/src/host/prompt.js
index 33ab64cf..cba8eb77 100644
--- a/ds-bot/src/host/prompt.js
+++ b/ds-bot/src/host/prompt.js
@@ -13,7 +13,7 @@ const TEAM_RULES = [
'- Chat like a teammate texting: short sentences, often two or three short messages instead of one long one, no headings. When the user asks for a deliverable (a plan, schedule, draft, or list), write it out in full in the chat; never claim you gave something you did not write. Mention other Bots by their exact name.',
'- Only for a direct user request in your own chat that needs several steps: write one short sentence of normal reply text before your first tool call, and make that tool call in the same response. Never start such a task with tools alone or end it with a promise. On long tasks, give brief factual updates only at meaningful milestones, then keep working.',
'- For "[Group chat …]", "[Message from …]", or "[Reply from …]" messages, do not write plans or progress updates: use tools silently, then reply with the answer. Simple answers do not need progress messages.',
- '- Offer choices with ask_user (a tap-to-answer card) instead of long option lists in text. Calling it ends your turn at once, so write everything you want to say before the call, in the same reply. The answer arrives as the user\'s next message. Never use ask_user_question: it blocks you, and messages from other Bots would queue behind it.',
+ '- Offer choices with ask_user (a tap-to-answer card) instead of long option lists in text. Calling it ends your turn at once, so write everything you want to say before the call, in the same reply. The answer arrives as the user\'s next message.',
'- update_bot changes your own settings: name, role label, color, model, or instructions. Leave out bot to change yourself. Use it when the user asks you to change how you are set up. Only a Main Bot can change other Bots; when another Bot needs changing, ask a Main Bot.',
'- You may be in group chats with the user and other Bots. You speak in each group from a separate conversation of yours, apart from your own chat with the user. There your turn arrives as a "[Group chat …]" message that shows the speaking order, and your reply is posted to the group. When someone there asks you to do something, do the work in that turn: the group goes on without waiting, and your final reply is posted when you finish. Any member can hand work to another with @Name, and the one that asked answers the result. In a group, read_own_chat shows your own chat (the group sees that you looked; share only what the group needs). In your own chat, read_group_chat shows what was said in a group. A group may have an admin, who steers it: the admin can call members with @Name, change the group with update_group, and start a new discussion there with post_to_group.',
'- When you need a key, token, or password, call request_secret: the user types it into a secure card and you never see it. Never ask the user to paste one into the chat. Use it through its environment variable ($DSH_SECRET_<NAME> in bash, $env:DSH_SECRET_<NAME> in PowerShell) and never print it. list_secrets shows which keys exist.',
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index ecb47972..afba0d52 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -7,6 +7,7 @@ import { unquote } from './text.js'
export const output = { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: String(value) }] }
export const GROUP_REF = { type: 'string', required: true, description: 'Exact group chat name from list_bots' }
+const BLOCKING_QUESTION_TOOL = 'ask_user_question'
const MODE_PARAM = {
type: 'string',
enum: ROOM_MODES,
@@ -425,6 +426,38 @@ export function install(rt) {
},
}))
+ // dsh's own question tool holds the turn open until the user answers, and every
+ // message from another Bot or a group round queues behind it. Bot Sessions ask
+ // through ask_user instead, so the tool is taken out of their tool list.
+ const hiddenQuestion = new WeakSet()
+ const hideBlockingQuestion = (agent) => {
+ if (agent === undefined || hiddenQuestion.has(agent) || !rt.isBotSession(agent.session?.id)) return
+ if (typeof agent.ctx?.tools?.restrict !== 'function') return
+ try {
+ // restrict() throws on a name this profile does not serve.
+ if (!ctx.tools.schemas(agent).some(schema => schema.name === BLOCKING_QUESTION_TOOL)) return
+ agent.ctx.tools.restrict({ deny: [BLOCKING_QUESTION_TOOL] })
+ hiddenQuestion.add(agent)
+ } catch (error) {
+ rt.warn('ds-bot: %s stays in the tool list of %s: %s', BLOCKING_QUESTION_TOOL, agent.session?.id, error)
+ }
+ }
+ // A new Bot, part, or group Session gets its Agent before ds-bot records it, so the
+ // list is only trimmed once ds-bot resolves that Agent again; the guard refuses
+ // the tool in any Bot Session meanwhile.
+ ctx.tools.guard(exec => (exec.name === BLOCKING_QUESTION_TOOL && rt.isBotSession(exec.agent?.id)
+ ? `Bots cannot use ${BLOCKING_QUESTION_TOOL}. Ask with ask_user in your own chat, or ask in your reply.`
+ : undefined))
+ // Creation waits for this listener, so the Agent's first step already lacks the tool.
+ ctx.on('agent/created', async ({ agent }) => {
+ try {
+ await rt.load()
+ hideBlockingQuestion(agent)
+ } catch (error) {
+ rt.warn('ds-bot: hiding %s on agent/created failed: %s', BLOCKING_QUESTION_TOOL, error)
+ }
+ })
+
ctx.tools.register(defineTool({
name: 'list_capabilities',
description: 'List shared MCP servers, skills, and packs, plus the capabilities attached to you.',
@@ -523,5 +556,5 @@ export function install(rt) {
}))
}
- Object.assign(rt, { pickRoom })
+ Object.assign(rt, { pickRoom, hideBlockingQuestion })
}
diff --git a/ds-bot/test/blocking-question.test.js b/ds-bot/test/blocking-question.test.js
new file mode 100644
index 00000000..4b9db5a6
--- /dev/null
+++ b/ds-bot/test/blocking-question.test.js
@@ -0,0 +1,146 @@
+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 { createRuntime } from '../index.js'
+import { fakeContext } from './fake-ctx.js'
+
+const QUESTION = 'ask_user_question'
+
+const team = () => ({
+ version: 1,
+ mainBotIds: ['chief'],
+ bots: {
+ chief: { id: 'chief', sessionId: 'chief', name: 'Chief', role: 'Lead', instructions: '', createdAt: 1 },
+ writer: { id: 'writer', sessionId: 'writer', name: 'Writer', role: 'Write', instructions: '', createdAt: 2 },
+ },
+ rooms: { room: { id: 'room', name: 'Desk', members: ['chief', 'writer'], sessions: { writer: 'room-writer' }, admin: 'chief', mode: 'everyone' } },
+ agents: { dsh: { id: 'dsh', name: 'DSH Agent', sessions: ['plain'], createdAt: 3 } },
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+ revision: 1,
+})
+
+// dsh keeps one Agent per Session and fires agent/created, waiting for its listeners,
+// the first time a Session resolves one. restrict() calls are recorded per Session.
+async function setup({ served = ['read', 'ask_user', QUESTION] } = {}) {
+ const home = mkdtempSync(join(tmpdir(), 'ds-bot-blocking-question-'))
+ writeFileSync(join(home, 'state.json'), JSON.stringify(team()))
+ const ctx = fakeContext()
+ const agents = new Map()
+ const hidden = []
+ const sent = []
+ let sessions = 0
+ const created = agent => Promise.all((ctx.listeners.get('agent/created') ?? []).map(listener => listener({ agent })))
+ const agentFor = async (id) => {
+ if (agents.has(id)) return agents.get(id)
+ const agent = {
+ id,
+ session: { id },
+ ctx: {
+ tools: { restrict: (filter) => { hidden.push([id, [...filter.deny]]); return () => {} } },
+ effect: execute => execute(),
+ },
+ followup: message => sent.push({ sessionId: id, message }),
+ }
+ agents.set(id, agent)
+ await created(agent)
+ return agent
+ }
+ ctx.tools.schemas = () => served.map(name => ({ name }))
+ Object.assign(ctx, {
+ llm: {
+ listProviders: () => [{ id: 'deepseek', name: 'DeepSeek' }],
+ listModels: async () => [{ id: 'deepseek-v4-flash' }],
+ resolveModelInfo: async () => ({}),
+ },
+ workspaceRegistry: {
+ get: () => undefined,
+ resolveByPath: async () => undefined,
+ create: async path => ({ id: 'w1', path }),
+ archiveSession: async () => {},
+ },
+ sessionController: {
+ create: async () => ({ sessionId: `new${++sessions}` }),
+ resolveAgent: async id => ({ agent: await agentFor(id) }),
+ selectModel: async () => {},
+ },
+ sessionTitle: { rename: async () => {} },
+ sessions: { flush: async () => {} },
+ })
+ const rt = createRuntime(ctx, { home, github: false, diagnosticsFile: false })
+ await rt.load()
+ const guard = (name, sessionId) => ctx.guards.map(check => check({ name, agent: sessionId === undefined ? undefined : { id: sessionId } })).find(reason => reason !== undefined)
+ const hiddenIn = id => hidden.filter(([sessionId, deny]) => sessionId === id && deny.includes(QUESTION))
+ const stop = async () => {
+ await ctx.dispose()
+ rmSync(home, { recursive: true, force: true, maxRetries: 5 })
+ }
+ return { ctx, rt, agentFor, hidden, hiddenIn, guard, sent, stop }
+}
+
+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 new Promise(resolve => setTimeout(resolve, 20))
+ }
+}
+
+test('a Bot\'s own chat and its group Session lose dsh\'s blocking question tool; other Sessions keep it', async (t) => {
+ const { agentFor, hidden, hiddenIn, stop } = await setup()
+ t.after(stop)
+ for (const id of ['chief', 'writer', 'room-writer', 'plain', 'elsewhere']) await agentFor(id)
+ assert.equal(hiddenIn('chief').length, 1)
+ assert.equal(hiddenIn('writer').length, 1)
+ assert.equal(hiddenIn('room-writer').length, 1)
+ assert.deepEqual(hiddenIn('plain'), [])
+ assert.deepEqual(hiddenIn('elsewhere'), [])
+ // The mask names only that tool, never ds-bot's own ask_user.
+ for (const [sessionId, deny] of hidden.filter(([id]) => id !== 'plain')) assert.deepEqual([sessionId, deny], [sessionId, [QUESTION]])
+})
+
+test('ds-bot resolving a Bot\'s Agent again does not hide the tool twice', async (t) => {
+ const { rt, hiddenIn, stop } = await setup()
+ t.after(stop)
+ await rt.resolveAgent('writer')
+ await rt.resolveAgent('writer')
+ await rt.deliver({ fromId: 'chief', toId: 'writer', text: 'hi', role: 'request' })
+ assert.equal(hiddenIn('writer').length, 1)
+})
+
+test('a profile without the tool gets no mask, which restrict() would refuse', async (t) => {
+ const { agentFor, hidden, guard, stop } = await setup({ served: ['read', 'ask_user'] })
+ t.after(stop)
+ await agentFor('writer')
+ assert.deepEqual(hidden, [])
+ // The guard still holds should a later profile serve it.
+ assert.match(guard(QUESTION, 'writer'), /Bots cannot use ask_user_question/)
+})
+
+test('the guard refuses the blocking question tool in Bot Sessions only', async (t) => {
+ const { guard, stop } = await setup()
+ t.after(stop)
+ for (const sessionId of ['chief', 'writer', 'room-writer']) assert.match(guard(QUESTION, sessionId), /Ask with ask_user in your own chat, or ask in your reply\./)
+ for (const sessionId of ['plain', 'elsewhere', undefined]) assert.equal(guard(QUESTION, sessionId), undefined)
+ assert.equal(guard('ask_user', 'writer'), undefined)
+ assert.equal(guard('read', 'writer'), undefined)
+})
+
+// FeiZhuLulu/DeepSeek-Bot#77: a new Bot told never to use a question tool was opened
+// with "use ask_user", and a model that picked dsh's ask_user_question for it held the
+// Bot until the card was answered, with other Bots' messages queued behind it.
+test('a new Bot that rules out question tools opens without one and cannot block on dsh\'s', async (t) => {
+ const { rt, hiddenIn, guard, sent, stop } = await setup()
+ t.after(stop)
+ const receiver = await rt.createBot({ name: 'Receiver', instructions: 'Never use ask_user or any question tool.', createdBy: 'chief' })
+ await until(() => sent.some(entry => entry.sessionId === receiver.id))
+ const kickoff = sent.find(entry => entry.sessionId === receiver.id).message.content[0].text
+ assert.doesNotMatch(kickoff, /ask_user|allowCustom/)
+ assert.match(kickoff, /Where your instructions say otherwise, follow them\./)
+ // The Agent was made before Receiver was on the team; the kickoff trims its list.
+ assert.equal(hiddenIn(receiver.id).length, 1)
+ assert.match(guard(QUESTION, receiver.id), /Bots cannot use ask_user_question/)
+})
diff --git a/ds-bot/test/fake-ctx.js b/ds-bot/test/fake-ctx.js
index 1d893f48..62fed26b 100644
--- a/ds-bot/test/fake-ctx.js
+++ b/ds-bot/test/fake-ctx.js
@@ -4,12 +4,14 @@ export function fakeContext({ services = {} } = {}) {
const calls = []
const disposers = []
const registeredTools = new Map()
+ const guards = []
// Listeners by event name, in registration order.
const listeners = new Map()
const sections = new Map()
const ctx = {
calls,
registeredTools,
+ guards,
listeners,
sections,
logger: { warn() {}, info() {} },
@@ -40,6 +42,12 @@ export function fakeContext({ services = {} } = {}) {
registeredTools.set(tool.name, tool)
return () => {}
},
+ guard(guard) {
+ calls.push('tools guard')
+ guards.push(guard)
+ return () => {}
+ },
+ schemas: () => [],
},
systemPrompt: {
section(section) {
diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.js
index d83c376d..23909084 100644
--- a/ds-bot/test/install.test.js
+++ b/ds-bot/test/install.test.js
@@ -53,6 +53,8 @@ test('apply registers listeners, tools, and effects in a fixed order', (t) => {
'tool delete_group',
'tool post_to_group',
'tool ask_user',
+ 'tools guard',
+ 'on agent/created',
'tool list_capabilities',
'tool save_capability',
'tool delete_capability',