Skip to content

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

Keep a Bot's other avatar fields when update_bot sets its photo

Fei241154100af87bc1
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index a5f638f9..c40b41e4 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -309,9 +309,12 @@ export function install(rt) {
let avatar
if (args.avatar !== undefined) {
const input = typeof args.avatar === 'string' ? args.avatar.trim() : args.avatar
+ // The photo rides on the Bot's other avatar fields, as the settings page's
+ // upload does: setting one keeps a custom character, and clearing removes
+ // only the image so the character shows again.
avatar = input === null || input === ''
- ? null
- : { image: await readAvatar(String(input), { baseDir: rt.sessionFolder?.(exec.agent?.session ?? exec.agent) }) }
+ ? { ...bot.avatar, image: null }
+ : { ...bot.avatar, image: await readAvatar(String(input), { baseDir: rt.sessionFolder?.(exec.agent?.session ?? exec.agent) }) }
}
const moving = typeof args.work_dir === 'string'
const workDir = moving ? await rt.cleanWorkDir(args.work_dir) : undefined
diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.js
index 38842dbe..4c03fd31 100644
--- a/ds-bot/test/roster.test.js
+++ b/ds-bot/test/roster.test.js
@@ -812,6 +812,24 @@ test('create_bot stores a photo, and update_bot changes and clears it', async (t
assert.equal((await writer()).avatar.image, PNG_DATA_URL)
})
+test('a photo through update_bot keeps the Bot\'s other avatar fields', async (t) => {
+ const { ctx, call, stop, sent } = start(undefined, { models: ['deepseek-v4-flash'] })
+ t.after(stop)
+ const chief = (await call('state', {})).value.mainBotId
+ const exec = { agent: { id: chief } }
+ assert.match(await ctx.registeredTools.get('create_bot').execute({ name: 'Writer', role: 'Write', instructions: 'Write' }, exec), /^Created Writer/)
+ const writer = async () => (await call('state', {})).value.bots.find(bot => bot.name === 'Writer')
+ const writerId = (await writer()).id
+ await until(() => sent.some(entry => entry.sessionId === writerId))
+ await call('update-bot', { id: writerId, avatar: { shape: 'fox' } })
+ const tool = args => ctx.registeredTools.get('update_bot').execute({ bot: 'Writer', ...args }, exec)
+ // Setting a photo keeps the character; clearing the photo keeps it too.
+ assert.equal(await tool({ avatar: PNG_DATA_URL }), 'Updated Writer.')
+ assert.deepEqual((await writer()).avatar, { shape: 'fox', image: PNG_DATA_URL })
+ assert.equal(await tool({ avatar: '' }), 'Updated Writer.')
+ assert.deepEqual((await writer()).avatar, { shape: 'fox' })
+})
+
test('a photo that cannot be read changes nothing, and a non-Main Bot cannot set another Bot\'s', async (t) => {
const { ctx, call, stop, sent } = start(undefined, { models: ['deepseek-v4-flash'] })
t.after(stop)