Skip to content

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

Relay group chats under the PTC agent preset

Fei241171d4b5ca8875
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8b2fec5..52b9d48d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
## [Unreleased]
+### 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))
+
## [0.1.5] - 2026-10-13
### Added
diff --git a/ds-bot/src/host/groups.js b/ds-bot/src/host/groups.js
index 7dbcc2ca..6e0acb72 100644
--- a/ds-bot/src/host/groups.js
+++ b/ds-bot/src/host/groups.js
@@ -673,9 +673,15 @@ export function install(rt) {
return
}
const id = `toolu_relay_${randomUUID().replace(/-/g, '')}`
+ const declared = new Set((options.tools ?? []).map(tool => tool.name))
+ // Only for a group made under the PTC preset, which can call nothing but run_code;
+ // new group Sessions get the standard preset.
+ const [name, args] = declared.has('run_code') && !declared.has('group_relay')
+ ? ['run_code', JSON.stringify({ description: 'Relay the group chat to its Bots', code: 'return await tools.group_relay({})', timeoutMs: 600_000 })]
+ : ['group_relay', '{}']
yield { type: 'block-start', index: 0, blockType: 'tool-call' }
- yield { type: 'tool-call-delta', index: 0, id, name: 'group_relay', argumentsDelta: '{}' }
- yield { type: 'block-end', index: 0, block: { type: 'tool-call', id, name: 'group_relay', arguments: '{}' } }
+ yield { type: 'tool-call-delta', index: 0, id, name, argumentsDelta: args }
+ yield { type: 'block-end', index: 0, block: { type: 'tool-call', id, name, arguments: args } }
yield { type: 'finish', reason: { kind: 'tool-calls' } }
})()
})
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index 2c95d080..8c6c49a3 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -21,6 +21,16 @@ export function install(rt) {
return workspace.id
}
+ // Under the PTC preset (DSH Desktop's default) a model may call only run_code, which
+ // turns down the group_relay call that a group chat's Session is given. A Session
+ // keeps the preset it is made with.
+ async function botPreset() {
+ const presets = ctx.get?.('agentPresets')
+ if (presets === undefined) return {}
+ const standard = (await presets.list()).some(preset => preset.id === 'standard' && preset.broken === undefined)
+ return standard ? { agentPreset: 'standard' } : {}
+ }
+
// `dir` is a working folder outside the team workspace. Such a Session is made by cwd
// alone, so it joins no DSH workspace and the user's own project lists stay as they are.
async function createSession(title, { dir } = {}) {
@@ -30,7 +40,8 @@ export function install(rt) {
if (readOnly !== undefined) throw new Error(readOnly)
const usable = dir !== undefined && await rt.isFolder(dir)
if (dir !== undefined && !usable) rt.warn('ds-bot: the working folder %s is gone; %s starts in the team workspace', dir, title)
- const { sessionId } = await ctx.sessionController.create(usable ? { cwd: dir } : { workspaceId: await ensureWorkspace() })
+ const place = usable ? { cwd: dir } : { workspaceId: await ensureWorkspace() }
+ const { sessionId } = await ctx.sessionController.create({ ...place, ...await botPreset() })
const agent = await rt.resolveAgent(sessionId)
await ctx.sessionTitle.rename(agent.session, title)
return sessionId
diff --git a/ds-bot/test/agent-preset.test.js b/ds-bot/test/agent-preset.test.js
new file mode 100644
index 00000000..88ea24a4
--- /dev/null
+++ b/ds-bot/test/agent-preset.test.js
@@ -0,0 +1,109 @@
+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'
+
+// Fei2411/DeepSeek-Bot#37: under DSH Desktop's default PTC preset a model may call only
+// run_code, so the group_relay call made for a group chat's Session was turned down
+// and no group message reached its Bots.
+
+const TEAM = {
+ version: 1,
+ mainBotIds: ['chief'],
+ revision: 1,
+ whaleStored: true,
+ bots: { chief: { id: 'chief', sessionId: 'chief', name: 'Chief', role: 'Lead', instructions: '', createdAt: 1 } },
+ rooms: { room: { id: 'room', name: 'Desk', members: ['chief'], admin: 'chief', mode: 'everyone', sessions: {}, seq: 0, log: [] } },
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+}
+
+function start({ presets } = {}) {
+ const home = mkdtempSync(join(tmpdir(), 'ds-bot-agent-preset-'))
+ writeFileSync(join(home, 'state.json'), JSON.stringify(TEAM))
+ const services = presets === undefined ? {} : { agentPresets: { list: async () => presets } }
+ const ctx = fakeContext({ services })
+ const created = []
+ Object.assign(ctx, {
+ workspaceRegistry: {
+ get: id => (id === 'w1' ? { id } : undefined),
+ resolveByPath: async () => undefined,
+ create: async path => ({ id: 'w1', path }),
+ archiveSession: async () => {},
+ },
+ sessionController: {
+ create: async (request) => {
+ created.push(request)
+ return { sessionId: `new${created.length}` }
+ },
+ resolveAgent: async id => ({ agent: { id, session: { id } } }),
+ },
+ sessionTitle: { rename: async () => {} },
+ })
+ const rt = createRuntime(ctx, { home, github: false, diagnosticsFile: false })
+ const relay = ctx.listeners.get('llm/stream').find(listener => /relayOrPass/.test(String(listener)))
+ const stop = async () => {
+ await ctx.dispose()
+ rmSync(home, { recursive: true, force: true, maxRetries: 5 })
+ }
+ return { rt, created, relay, stop }
+}
+
+async function drain(stream) {
+ const chunks = []
+ for await (const chunk of stream) chunks.push(chunk)
+ return chunks
+}
+
+const userText = text => ({ role: 'user', source: { kind: 'user' }, content: [{ type: 'text', text }] })
+const declared = (...names) => names.map(name => ({ name, description: '', parameters: {} }))
+const relayCall = async (relay, tools) => {
+ const chunks = await drain(relay({ provider: 'deepseek', model: 'v4', sessionId: 'room', messages: [userText('Hello team')], tools }, () => {
+ throw new Error('a group round never reaches the model')
+ }))
+ assert.equal(chunks.at(-1).reason.kind, 'tool-calls')
+ return chunks.find(chunk => chunk.type === 'block-end').block
+}
+
+test('a new Bot Session is made with the standard preset when DSH serves it', async (t) => {
+ const { rt, created, stop } = start({ presets: [{ id: 'ptc' }, { id: 'standard' }] })
+ t.after(stop)
+ await rt.load()
+ await rt.createSession('Chief')
+ assert.deepEqual(created, [{ workspaceId: 'w1', agentPreset: 'standard' }])
+})
+
+test('without a usable standard preset a Bot Session keeps DSH\'s default', async (t) => {
+ for (const presets of [undefined, [{ id: 'ptc' }], [{ id: 'standard', broken: 'failed to start' }]]) {
+ const { rt, created, stop } = start({ presets })
+ t.after(stop)
+ await rt.load()
+ await rt.createSession('Chief')
+ assert.deepEqual(created, [{ workspaceId: 'w1' }])
+ }
+})
+
+test('a group round calls group_relay directly when the Session declares it', async (t) => {
+ const { relay, stop } = start()
+ t.after(stop)
+ for (const tools of [declared('read', 'group_relay'), declared('run_code', 'group_relay')]) {
+ const block = await relayCall(relay, tools)
+ assert.deepEqual([block.name, block.arguments], ['group_relay', '{}'])
+ }
+})
+
+test('a group made under the PTC preset relays through run_code', async (t) => {
+ const { relay, stop } = start()
+ t.after(stop)
+ const block = await relayCall(relay, declared('run_code'))
+ assert.equal(block.name, 'run_code')
+ assert.deepEqual(JSON.parse(block.arguments), {
+ description: 'Relay the group chat to its Bots',
+ code: 'return await tools.group_relay({})',
+ timeoutMs: 600_000,
+ })
+})