Skip to content

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

Stop DSH goals in Bot chats and group chats

Fei2411e7ffb9f8568f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52b9d48d..25c418e9 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
- Group chats now relay messages to their Bots with the `ptc` agent preset, DSH Desktop's default. New Bot chats, group chats and conversation parts use the `standard` preset. A group chat made under `ptc` still relays, but each of its rounds is limited by DSH's time limit for a program run, about 10 minutes. ([#37](https://github.com/Fei2411/DeepSeek-Bot/issues/37))
+- Bot chats and group chats no longer run DeepSeek Harness goals. A goal started there with `/goal` is stopped at once with a short note, so a group chat no longer runs round after round, and the chat shows no goal rounds. ([#133](https://github.com/Fei2411/DeepSeek-Bot/issues/133))
## [0.1.5] - 2026-10-13
diff --git a/ds-bot/client.js b/ds-bot/client.js
index f46d6417..a811b0ae 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -4176,7 +4176,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
const prompts = reminderPrompts(contentText(data.content));
return (0, import_react6.createElement)("div", { className: "bt-event" }, prompts.length > 0 ? t("Scheduled task: {text}", { text: prompts.join(" · ").slice(0, 80) }) : t("Routine started"));
}
- if (source.kind === "user-question-reply") return null;
+ if (source.kind === "user-question-reply" || source.kind === "goal") return null;
return (0, import_react6.createElement)("div", { className: "bt-event" }, contentText(data.content).slice(0, 80) || t("Update"));
}
}
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index a99dadca..d125adad 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -377,7 +377,7 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl
const prompts = reminderPrompts(contentText(data.content))
return h('div', { className: 'bt-event' }, prompts.length > 0 ? t('Scheduled task: {text}', { text: prompts.join(' · ').slice(0, 80) }) : t('Routine started'))
}
- if (source.kind === 'user-question-reply') return null
+ if (source.kind === 'user-question-reply' || source.kind === 'goal') return null
return h('div', { className: 'bt-event' }, contentText(data.content).slice(0, 80) || t('Update'))
}
}
diff --git a/ds-bot/src/host/delivery.js b/ds-bot/src/host/delivery.js
index ae2e8157..5b20edcb 100644
--- a/ds-bot/src/host/delivery.js
+++ b/ds-bot/src/host/delivery.js
@@ -9,7 +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)
+ rt.hideBotUnusedTools(resolved.agent)
return resolved.agent
}
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index ffaf7827..e25663d8 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -8,6 +8,10 @@ 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'
+// DS Bot carries no goal across conversation parts, so Bot Sessions do not run DSH goals.
+const GOAL_TOOLS = ['create_goal', 'update_goal', 'get_goal']
+const HIDDEN_TOOLS = [BLOCKING_QUESTION_TOOL, ...GOAL_TOOLS]
+const GOAL_REFUSAL = 'DS Bot does not run goals. Ask the Bot in a message instead.'
const MODE_PARAM = {
type: 'string',
enum: ROOM_MODES,
@@ -467,23 +471,26 @@ 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
+ // through ask_user instead, so the tool is taken out of their tool list, as are the
+ // goal tools.
+ const hiddenTools = new WeakSet()
+ const hideBotUnusedTools = (agent) => {
+ if (agent === undefined || hiddenTools.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)
+ const served = new Set(ctx.tools.schemas(agent).map(schema => schema.name))
+ const deny = HIDDEN_TOOLS.filter(name => served.has(name))
+ if (deny.length === 0) return
+ agent.ctx.tools.restrict({ deny })
+ hiddenTools.add(agent)
} catch (error) {
- rt.warn('ds-bot: %s stays in the tool list of %s: %s', BLOCKING_QUESTION_TOOL, agent.session?.id, error)
+ rt.warn('ds-bot: %s stay in the tool list of %s: %s', HIDDEN_TOOLS.join(', '), 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.
+ // list is only trimmed once ds-bot resolves that Agent again; meanwhile the guard
+ // refuses the question tool in any Bot Session, and a goal made there is blocked.
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))
@@ -491,12 +498,42 @@ export function install(rt) {
ctx.on('agent/created', async ({ agent }) => {
try {
await rt.load()
- hideBlockingQuestion(agent)
+ hideBotUnusedTools(agent)
} catch (error) {
- rt.warn('ds-bot: hiding %s on agent/created failed: %s', BLOCKING_QUESTION_TOOL, error)
+ rt.warn('ds-bot: hiding %s on agent/created failed: %s', HIDDEN_TOOLS.join(', '), error)
}
})
+ // The /goal command stays open in every Session, so a goal started in a Bot chat or a
+ // group is blocked at once; DSH's round driver then starts no round for it.
+ let goals = null
+ const attachGoals = (sub) => {
+ const own = sub.goals
+ goals = own
+ sub.effect(() => () => { if (goals === own) goals = null }, 'ds-bot: goal service')
+ }
+ if (typeof ctx.inject === 'function') ctx.inject(['goals'], attachGoals)
+ else if (ctx.get?.('goals') !== undefined) attachGoals({ goals: ctx.get('goals'), effect: (execute, label) => ctx.effect(execute, label) })
+ const blockGoal = async (sessionId) => {
+ const service = goals
+ if (service === null) return
+ try {
+ const agent = await rt.resolveAgent(sessionId)
+ const goal = service.get(agent)
+ if (goal?.phase !== 'active') return
+ service.block(agent, { id: goal.id, revision: goal.revision }, { code: 'not-supported', message: GOAL_REFUSAL })
+ } catch (error) {
+ rt.warn('ds-bot: blocking the goal in %s failed: %s', sessionId, error)
+ }
+ }
+ ctx.on('session/event', (session, event) => {
+ if (event.type !== 'goal/change' || event.data?.goal?.phase !== 'active') return
+ const id = session?.id
+ if (!rt.isBotSession(id) && rt.roomOf(id) === undefined) return
+ // block() appends to the same log, so it waits until every listener has seen this change.
+ setTimeout(() => void blockGoal(id), 0)
+ })
+
ctx.tools.register(defineTool({
name: 'list_capabilities',
description: 'List shared MCP servers, skills, and packs, plus the capabilities attached to you.',
@@ -595,5 +632,5 @@ export function install(rt) {
}))
}
- Object.assign(rt, { pickRoom, hideBlockingQuestion })
+ Object.assign(rt, { pickRoom, hideBotUnusedTools })
}
diff --git a/ds-bot/test/blocking-question.test.js b/ds-bot/test/blocking-question.test.js
index 4b9db5a6..0eec5b9a 100644
--- a/ds-bot/test/blocking-question.test.js
+++ b/ds-bot/test/blocking-question.test.js
@@ -25,10 +25,10 @@ const team = () => ({
// 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] } = {}) {
+async function setup({ served = ['read', 'ask_user', QUESTION], goals } = {}) {
const home = mkdtempSync(join(tmpdir(), 'ds-bot-blocking-question-'))
writeFileSync(join(home, 'state.json'), JSON.stringify(team()))
- const ctx = fakeContext()
+ const ctx = fakeContext({ services: goals === undefined ? {} : { goals } })
const agents = new Map()
const hidden = []
const sent = []
@@ -81,6 +81,31 @@ async function setup({ served = ['read', 'ask_user', QUESTION] } = {}) {
return { ctx, rt, agentFor, hidden, hiddenIn, guard, sent, stop }
}
+// DSH's goal service, holding one goal per Session; block() records what was asked.
+function goalService() {
+ const current = new Map()
+ const blocked = []
+ return {
+ current,
+ blocked,
+ get: agent => current.get(agent.id),
+ block(agent, ref, reason) {
+ const goal = current.get(agent.id)
+ assert.deepEqual(ref, { id: goal.id, revision: goal.revision })
+ blocked.push({ sessionId: agent.id, ...reason })
+ current.set(agent.id, { ...goal, revision: goal.revision + 1, phase: 'blocked' })
+ },
+ }
+}
+
+// What DSH logs when /goal starts a goal: a snapshot change of the Session's goal log.
+const startGoal = (ctx, goals, sessionId) => {
+ const goal = { id: `goal-${sessionId}`, revision: 1, objective: 'Ship it', phase: 'active', maxGoalRounds: 256 }
+ goals?.current.set(sessionId, goal)
+ const event = { type: 'goal/change', data: { kind: 'goal/change', version: 1, operation: 'create', goal, roundsStarted: 0, createdAt: 1, updatedAt: 1 } }
+ for (const listener of ctx.listeners.get('session/event') ?? []) listener({ id: sessionId }, event)
+}
+
const until = async (check) => {
const end = Date.now() + 2000
while (!check()) {
@@ -144,3 +169,43 @@ test('a new Bot that rules out question tools opens without one and cannot block
assert.equal(hiddenIn(receiver.id).length, 1)
assert.match(guard(QUESTION, receiver.id), /Bots cannot use ask_user_question/)
})
+
+// Fei2411/DeepSeek-Bot#133: /goal in a group chat started DSH's goal rounds, which the
+// group never answered, so round after round ran and showed the raw goal prompt.
+test('a Bot\'s chat and its group Sessions lose the goal tools; other Sessions keep them', async (t) => {
+ const { agentFor, hidden, stop } = await setup({ served: ['read', 'ask_user', QUESTION, 'create_goal', 'update_goal', 'get_goal'] })
+ t.after(stop)
+ for (const id of ['chief', 'room-writer', 'plain']) await agentFor(id)
+ // A DSH Agent Session ('plain') has its own mask, which leaves the goal tools.
+ assert.deepEqual(hidden.filter(([, deny]) => deny.includes('create_goal')), [
+ ['chief', [QUESTION, 'create_goal', 'update_goal', 'get_goal']],
+ ['room-writer', [QUESTION, 'create_goal', 'update_goal', 'get_goal']],
+ ])
+})
+
+test('a goal started in a Bot chat or a group is blocked; one elsewhere runs', async (t) => {
+ const goals = goalService()
+ const { ctx, agentFor, stop } = await setup({ goals })
+ t.after(stop)
+ const ids = ['writer', 'room', 'room-writer', 'plain']
+ for (const id of ids) await agentFor(id)
+ for (const id of ids) startGoal(ctx, goals, id)
+ // The block waits until DSH has handed the change to every listener.
+ assert.deepEqual(goals.blocked, [])
+ await until(() => goals.blocked.length === 3)
+ await new Promise(resolve => setTimeout(resolve, 20))
+ assert.deepEqual(goals.blocked.map(entry => entry.sessionId), ['writer', 'room', 'room-writer'])
+ for (const entry of goals.blocked) assert.deepEqual([entry.code, entry.message], ['not-supported', 'DS Bot does not run goals. Ask the Bot in a message instead.'])
+ assert.equal(goals.current.get('plain').phase, 'active')
+})
+
+test('without DSH\'s goal service a goal change is left alone', async (t) => {
+ const { ctx, rt, agentFor, stop } = await setup()
+ t.after(stop)
+ const warnings = []
+ rt.warn = (...args) => warnings.push(args)
+ await agentFor('writer')
+ startGoal(ctx, undefined, 'writer')
+ await new Promise(resolve => setTimeout(resolve, 20))
+ assert.deepEqual(warnings, [])
+})
diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.js
index 23909084..e7ca4160 100644
--- a/ds-bot/test/install.test.js
+++ b/ds-bot/test/install.test.js
@@ -55,6 +55,7 @@ test('apply registers listeners, tools, and effects in a fixed order', (t) => {
'tool ask_user',
'tools guard',
'on agent/created',
+ 'on session/event',
'tool list_capabilities',
'tool save_capability',
'tool delete_capability',
diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.js
index f708555b..417c6221 100644
--- a/ds-bot/test/tool-cells.test.js
+++ b/ds-bot/test/tool-cells.test.js
@@ -9,7 +9,7 @@ import { build } from 'esbuild'
const { outputFiles } = await build({
stdin: {
contents: [
- "export { ToolCell, callTree } from './src/client/cells.js'",
+ "export { ToolCell, TriggerCell, callTree } from './src/client/cells.js'",
"export { QuestionDock } from './src/client/questions.js'",
"export { SecretDock } from './src/client/secret-card.js'",
"export { countCards } from './src/client/sources.js'",
@@ -44,7 +44,7 @@ runInNewContext(outputFiles[0].text, {
throw new Error(`Unexpected platform module ${name}`)
},
})
-const { ToolCell, callTree, QuestionDock, SecretDock, countCards } = module.exports
+const { ToolCell, TriggerCell, callTree, QuestionDock, SecretDock, countCards } = module.exports
// Runs the effects collected since the last render; returns the cleanups.
const mount = () => {
@@ -355,3 +355,18 @@ test('PTC secret and question cards show at their sub-calls and act on their own
assert.doesNotMatch(shown(program([call('ask_user', 'call-0-1:ptc:1')]), { roster }), /Which draft\?/)
assert.equal(shown(program([call('ask_user', 'call-1-2:ptc:1')]), { roster: team() }), '')
})
+
+// #133: a DSH goal round showed its raw <goal_round> prompt as an event line.
+test('a goal round draws nothing, while another unknown trigger keeps its event line', () => {
+ const trigger = source => expand(TriggerCell({
+ node: { key: 'node', data: { source, turn: 2, content: text$('<goal_round>Keep going</goal_round>') }, location: { turn: { turn: 2 } } },
+ sessionId: 'room',
+ useRoster: select => select(team()),
+ useSessions: select => select({ byId: {} }),
+ useTurnClock: select => select({}),
+ useUi: select => select({ visits: {} }),
+ actions: {},
+ }))
+ assert.equal(trigger({ kind: 'goal', goalId: 'goal-1', revision: 1, round: 1 }), null)
+ assert.match(text(trigger({ kind: 'webhook' })), /<goal_round>Keep going/)
+})