Skip to content

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

Let every Bot update its own settings with update_bot

FeiZhuLulu3e2642f7f62a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3711f2a0..83de4c1d 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]
+### Changed
+
+- Every Bot can change its own name, role, color, model and instructions; only a Main Bot changes other Bots.
+
## [0.1.2] - 2026-10-11
### Added
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 52c84b7f..acc2892d 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -4025,7 +4025,7 @@ var TOOL_PHRASES = [
[/image|photo|draw/i, "Working on an image"]
];
var GROUP_PHRASES = { create_group: "Creating a group", update_group: "Updating the group", delete_group: "Deleting the group", post_to_group: "Posting in the group" };
-function toolActivity(name, arg, findBot) {
+function toolActivity(name, arg, findBot, self2) {
switch (name) {
case "ask_user":
return null;
@@ -4044,7 +4044,7 @@ function toolActivity(name, arg, findBot) {
case "create_bot":
return { label: t("Creating {name}", { name: arg("name") ?? t("a Bot") }), state: "sending" };
case "update_bot": {
- const target = findBot(arg("name")) ?? findBot(arg("bot"));
+ const target = findBot(arg("name")) ?? findBot(arg("bot")) ?? (arg("bot") ? void 0 : self2);
return { label: t("Updating {name}", { name: target?.name ?? t("a Bot") }), state: "sending" };
}
case "list_bots":
@@ -4150,7 +4150,7 @@ function ToolCell({ node, sessionId, useRoster, useUi, actions }) {
const tool = toolName(root);
const { text: arg, value: argValue } = toolArgs(root);
const findBot = (nameOrId) => roster.byId[nameOrId] ?? roster.bots.find((bot) => bot.name.toLowerCase() === String(nameOrId ?? "").toLowerCase());
- useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, done || hidden ? null : toolActivity(tool, arg, findBot));
+ useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, done || hidden ? null : toolActivity(tool, arg, findBot, roster.byId[sessionId]));
if (hidden) return null;
switch (tool) {
case "message_bot": {
@@ -4164,7 +4164,7 @@ function ToolCell({ node, sessionId, useRoster, useUi, actions }) {
return (0, import_react6.createElement)(EventLine, { prefix: t("Created"), bots: [created], onOpen: (bot) => actions.openSession(bot.id) });
}
case "update_bot": {
- const target = findBot(arg("name")) ?? findBot(arg("bot"));
+ const target = findBot(arg("name")) ?? findBot(arg("bot")) ?? (arg("bot") ? void 0 : roster.byId[sessionId]);
return done && target ? (0, import_react6.createElement)(EventLine, { prefix: t("Updated"), bots: [target], onOpen: (bot) => actions.openSession(bot.id) }) : null;
}
case "group_relay":
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index aa809c2a..09d80959 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -441,7 +441,7 @@ const TOOL_PHRASES = [
[/image|photo|draw/i, 'Working on an image'],
]
const GROUP_PHRASES = { create_group: 'Creating a group', update_group: 'Updating the group', delete_group: 'Deleting the group', post_to_group: 'Posting in the group' }
-function toolActivity(name, arg, findBot) {
+function toolActivity(name, arg, findBot, self) {
switch (name) {
case 'ask_user': return null
case 'request_secret': return null
@@ -454,7 +454,7 @@ function toolActivity(name, arg, findBot) {
}
case 'create_bot': return { label: t('Creating {name}', { name: arg('name') ?? t('a Bot') }), state: 'sending' }
case 'update_bot': {
- const target = findBot(arg('name')) ?? findBot(arg('bot'))
+ const target = findBot(arg('name')) ?? findBot(arg('bot')) ?? (arg('bot') ? undefined : self)
return { label: t('Updating {name}', { name: target?.name ?? t('a Bot') }), state: 'sending' }
}
case 'list_bots': return { label: t('Checking the team'), state: 'searching' }
@@ -538,7 +538,7 @@ export function ToolCell({ node, sessionId, useRoster, useUi, actions }) {
const { text: arg, value: argValue } = toolArgs(root)
const findBot = nameOrId => roster.byId[nameOrId] ?? roster.bots.find(bot => bot.name.toLowerCase() === String(nameOrId ?? '').toLowerCase())
// A running tool shows only as the activity row's phrase.
- useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, done || hidden ? null : toolActivity(tool, arg, findBot))
+ useLiveNote(actions, sessionId, `tool:${root.callId ?? node.key}`, done || hidden ? null : toolActivity(tool, arg, findBot, roster.byId[sessionId]))
if (hidden) return null
switch (tool) {
case 'message_bot': {
@@ -552,7 +552,7 @@ export function ToolCell({ node, sessionId, useRoster, useUi, actions }) {
return h(EventLine, { prefix: t('Created'), bots: [created], onOpen: bot => actions.openSession(bot.id) })
}
case 'update_bot': {
- const target = findBot(arg('name')) ?? findBot(arg('bot'))
+ const target = findBot(arg('name')) ?? findBot(arg('bot')) ?? (arg('bot') ? undefined : roster.byId[sessionId])
return done && target ? h(EventLine, { prefix: t('Updated'), bots: [target], onOpen: bot => actions.openSession(bot.id) }) : null
}
case 'group_relay':
diff --git a/ds-bot/src/host/prompt.js b/ds-bot/src/host/prompt.js
index aa4b6f34..aa7d0b68 100644
--- a/ds-bot/src/host/prompt.js
+++ b/ds-bot/src/host/prompt.js
@@ -12,6 +12,7 @@ const TEAM_RULES = [
'- When a "[Reply from …]" arrives, tell the user the outcome if it matters to them.',
'- 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.',
'- 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.',
+ '- 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. 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.',
'- web_search results say which search backend answered. If web_search fails, never guess URLs or present pages you remember as search results: use a browser tool if you have one, otherwise tell the user that search is unavailable and the reason it gave.',
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index 732a049b..b1f8be91 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -113,9 +113,9 @@ export function install(rt) {
ctx.tools.register(defineTool({
name: 'update_bot',
- description: 'Main Bot only. Rename a Bot or change its role, color, model, or instructions.',
+ description: 'Change a Bot\'s name, role, color, model, or instructions. Every Bot may change itself; only a Main Bot may change another Bot.',
parameters: {
- bot: { type: 'string', required: true, description: 'Current Bot name' },
+ bot: { type: 'string', description: 'Current name of the Bot to change; leave out to change yourself' },
name: { type: 'string', description: 'New name' },
role: { type: 'string', description: 'New role label' },
instructions: { type: 'string', description: 'Replacement instructions' },
@@ -125,9 +125,12 @@ export function install(rt) {
output,
async execute(args, exec) {
await rt.load()
- if (!rt.isMain(rt.selfOf(exec.agent?.id))) return 'Only the Main Bot can update Bots.'
- const bot = rt.findBot(args.bot)
+ const self = rt.selfOf(exec.agent?.id)
+ const caller = rt.botOf(self)
+ if (caller === undefined) return 'Only Bots on the team can use update_bot.'
+ const bot = args.bot ? rt.findBot(args.bot) : caller
if (bot === undefined) return `No Bot named ${args.bot}.`
+ if (bot.id !== caller.id && !rt.isMain(self)) return 'Only a Main Bot can change another Bot. Leave out bot to change yourself, or ask a Main Bot with message_bot.'
try {
const { name: newName, role, instructions, color, model } = args
const next = await rt.updateBot(bot.id, { name: newName, role, instructions, color, ...(model ? { model } : {}) })
diff --git a/ds-bot/test/update-bot.test.js b/ds-bot/test/update-bot.test.js
new file mode 100644
index 00000000..bc67de8e
--- /dev/null
+++ b/ds-bot/test/update-bot.test.js
@@ -0,0 +1,97 @@
+import assert from 'node:assert/strict'
+import { existsSync, mkdtempSync, readFileSync, 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: ['m1'],
+ revision: 1,
+ whaleStored: true,
+ bots: {
+ m1: { id: 'm1', sessionId: 'm1', name: 'Chief', role: 'Chief of Staff', model: 'deepseek/v4', instructions: '', createdAt: 1 },
+ b2: { id: 'b2', sessionId: 'b2', name: 'Writer', role: '写作', model: 'deepseek/v4', instructions: '', createdAt: 2 },
+ b3: { id: 'b3', sessionId: 'b3', name: 'Coder', role: '代码', instructions: '', createdAt: 3 },
+ },
+ rooms: {
+ r1: {
+ id: 'r1', name: 'Launch', named: true, members: ['b2', 'b3'], admin: 'b3', mode: 'everyone', notice: '', sessions: { b3: 'g3' },
+ seq: 0,
+ log: [],
+ },
+ },
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+}
+
+function start() {
+ const home = mkdtempSync(join(tmpdir(), 'ds-bot-update-'))
+ if (!existsSync(join(home, 'state.json'))) writeFileSync(join(home, 'state.json'), JSON.stringify(TEAM))
+ const ctx = fakeContext()
+ Object.assign(ctx, {
+ llm: {
+ listProviders: () => [{ id: 'deepseek', name: 'DeepSeek' }],
+ listModels: async () => [{ id: 'v4' }],
+ resolveModelInfo: async () => ({}),
+ },
+ sessionController: {
+ resolveAgent: async sessionId => ({ agent: { session: { id: sessionId, seq: 1 } } }),
+ selectModel: async () => {},
+ },
+ sessionTitle: { rename: async () => {} },
+ sessions: { flush: async () => {} },
+ workspaceRegistry: { archiveSession: async () => {} },
+ })
+ apply(ctx, { home })
+ const tool = (name, args, sessionId) => ctx.registeredTools.get(name).execute(args, { agent: { id: sessionId } })
+ const state = () => JSON.parse(readFileSync(join(home, 'state.json'), 'utf8'))
+ const stop = () => {
+ ctx.dispose()
+ rmSync(home, { recursive: true, force: true })
+ }
+ return { ctx, tool, state, stop }
+}
+
+test('a Bot changes itself by leaving out bot, or by naming itself', async (t) => {
+ const { tool, state, stop } = start()
+ t.after(stop)
+ assert.equal(await tool('update_bot', { name: 'King', instructions: 'Lead the team' }, 'b2'), 'Updated King.')
+ const king = state().bots.b2
+ assert.equal(king.name, 'King')
+ assert.equal(king.instructions, 'Lead the team')
+ // Its current name resolves to it again.
+ assert.equal(await tool('update_bot', { bot: 'King', role: '掌门' }, 'b2'), 'Updated King.')
+ assert.equal(state().bots.b2.role, '掌门')
+})
+
+test('a Bot cannot change another Bot; a Main Bot can', async (t) => {
+ const { tool, state, stop } = start()
+ t.after(stop)
+ assert.match(await tool('update_bot', { bot: 'Chief', role: 'boss' }, 'b2'), /^Only a Main Bot can change another Bot/)
+ assert.equal(state().bots.m1.role, 'Chief of Staff')
+ assert.equal(await tool('update_bot', { bot: 'Writer', role: '主笔' }, 'm1'), 'Updated Writer.')
+ assert.equal(state().bots.b2.role, '主笔')
+ assert.match(await tool('update_bot', { bot: 'Nobody' }, 'm1'), /^No Bot named Nobody/)
+})
+
+test('a group Session changes its own Bot; a Session outside the team changes nothing', async (t) => {
+ const { tool, state, stop } = start()
+ t.after(stop)
+ assert.equal(await tool('update_bot', { instructions: 'Ship the fix' }, 'g3'), 'Updated Coder.')
+ assert.equal(state().bots.b3.instructions, 'Ship the fix')
+ assert.equal(await tool('update_bot', { name: 'King' }, 'stranger'), 'Only Bots on the team can use update_bot.')
+})
+
+test('every Bot sees the update_bot rule in its identity section', async (t) => {
+ const { ctx, tool, stop } = start()
+ t.after(stop)
+ // The first load indexes the Sessions; without it selfOf finds no Bot.
+ await tool('list_bots', {}, 'b2')
+ const text = ctx.sections.get('bot-identity').text({ agent: { id: 'b2' } })
+ assert.match(text, /update_bot changes your own settings/)
+ assert.match(ctx.sections.get('bot-identity').text({ agent: { id: 'm1' } }), /update_bot changes your own settings/)
+})