Skip to content

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

Notify a self-edit only when it happened in the Bot's own chat

Fei241173a819c22cb8
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index 4be4f410..f37661b3 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -239,7 +239,7 @@ export function install(rt) {
})
}
- async function updateBot(id, patch, actorId) {
+ async function updateBot(id, patch, actorId, fromSessionId) {
const bot = rt.botOf(id)
if (bot === undefined) throw new Error('Unknown Bot')
if (patch.browserGrants !== undefined && actorId !== undefined) {
@@ -320,9 +320,12 @@ export function install(rt) {
if (bot.instructions !== instructionsBefore) notes.push(`Your instructions now read:\n${bot.instructions || '(none)'}`)
// A held greeting means the model pick is still open: the kickoff it later sends
// already reads the new profile, and a notice would start a turn before that.
- // A Bot editing itself just got the tool result in the turn that made the edit;
- // a notice there would only buy it a second, unsolicited reply.
- if (notes.length > 0 && bot.kickoff === undefined && actorId !== bot.id) {
+ // A Bot editing itself in its own chat just got the tool result in the turn
+ // that made the edit; a notice there would only buy it a second, unsolicited
+ // reply. The same edit made from a group Session reaches no own-chat turn, so
+ // the notice still goes out.
+ const selfEditInChat = actorId === bot.id && fromSessionId === rt.chatOf(bot.id)
+ if (notes.length > 0 && bot.kickoff === undefined && !selfEditInChat) {
void rt.deliver({ toId: bot.id, text: notes.join('\n'), role: 'update' })
.catch(error => rt.warn('ds-bot: profile update for %s not delivered: %s', bot.name, error?.message ?? error))
}
diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.js
index 7a7942f8..5fce67ef 100644
--- a/ds-bot/src/host/tools.js
+++ b/ds-bot/src/host/tools.js
@@ -365,7 +365,7 @@ export function install(rt) {
// does: setting one keeps a custom character, and clearing removes only the image.
// They are read here, after the waits above, so a change made meanwhile stays.
const avatar = image === undefined ? undefined : { ...rt.botOf(bot.id)?.avatar, image }
- const next = await rt.updateBot(bot.id, { name: newName, role, instructions, color, ...(avatar !== undefined ? { avatar } : {}), ...(model ? { model } : {}), ...(effort === undefined ? {} : { effort }), ...(moving ? { workDir: workDir ?? '' } : {}) }, self)
+ const next = await rt.updateBot(bot.id, { name: newName, role, instructions, color, ...(avatar !== undefined ? { avatar } : {}), ...(model ? { model } : {}), ...(effort === undefined ? {} : { effort }), ...(moving ? { workDir: workDir ?? '' } : {}) }, self, exec.agent?.id)
if (!moving) return `Updated ${next.name}.`
const folder = workDir ?? 'the team workspace'
return bot.id === caller.id ? `Updated ${next.name}. From your next step on, you work in ${folder}.` : `Updated ${next.name}. It now works in ${folder}.`
diff --git a/ds-bot/test/update-bot.test.js b/ds-bot/test/update-bot.test.js
index 9303414c..4b236db4 100644
--- a/ds-bot/test/update-bot.test.js
+++ b/ds-bot/test/update-bot.test.js
@@ -118,10 +118,15 @@ test('an instructions change lands as a message in the Bot chat', async (t) => {
await new Promise(resolve => setTimeout(resolve, 0))
assert.equal(sent.length, 1)
- // A Bot editing itself just got the tool result; no second turn queues for it.
+ // A Bot editing itself in its own chat just got the tool result; no second
+ // turn queues for it. The same edit from a group Session still reaches it.
assert.equal(await tool('update_bot', { instructions: 'Own fix' }, 'b2'), 'Updated Writer.')
await new Promise(resolve => setTimeout(resolve, 0))
assert.equal(sent.length, 1)
+ assert.equal(await tool('update_bot', { instructions: 'From the group' }, 'g3'), 'Updated Coder.')
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.equal(sent.length, 2)
+ assert.equal(sent[1].sessionId, 'b3')
})
test('a Bot whose greeting is still held gets no notice before its model pick', async (t) => {