Skip to content

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

Tell a Bot when its role or instructions change

Fei2411b39ef4aff5d7
diff --git a/ds-bot/src/host/delivery.js b/ds-bot/src/host/delivery.js
index 96220244..6c80a863 100644
--- a/ds-bot/src/host/delivery.js
+++ b/ds-bot/src/host/delivery.js
@@ -28,6 +28,7 @@ export function install(rt) {
if (role === 'room') return `[Group chat "${roomName}" · ${note}]`
if (role === 'report') return `[Group chat "${roomName}" · replies to your post${goesOn}]`
if (role === 'kickoff') return '[Bot team setup]'
+ if (role === 'update') return '[The user updated your profile — follow the latest version]'
if (role === 'secret') return '[Secret card]'
if (audience === 'user') return `[Message from ${fromName} · the user sees your reply here]`
return `[Message from ${fromName}]`
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index b4b79a9d..9ad04560 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -277,6 +277,8 @@ export function install(rt) {
await ctx.sessionTitle.rename(agent.session, next)
await followMemberNames(Object.values(state.rooms).filter(room => room.members.includes(id)))
}
+ const roleBefore = bot.role
+ const instructionsBefore = bot.instructions
if (patch.role !== undefined) bot.role = String(patch.role).trim().slice(0, 24)
if (patch.instructions !== undefined) bot.instructions = String(patch.instructions).trim()
let modelChanged = false
@@ -310,6 +312,16 @@ export function install(rt) {
else bot.workDir = workDir
}
await rt.save()
+ // The system prompt reads the live profile every turn, but a Session with
+ // several rounds behind it follows the old kickoff's pull until a message
+ // lands; notify the Bot's chat so the next turn honors the new profile.
+ const notes = []
+ if (bot.role !== roleBefore) notes.push(`Your role is now "${bot.role || '(none)'}"`)
+ if (bot.instructions !== instructionsBefore) notes.push(`Your instructions now read:\n${bot.instructions || '(none)'}`)
+ if (notes.length > 0) {
+ 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))
+ }
if (modelChanged) await rt.applyModel(bot, { force: true })
if (moved) void rt.followFolder(bot.id)
if (bot.model && bot.kickoff !== undefined) {
diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.js
index d9e47c6d..9f896655 100644
--- a/ds-bot/test/roster.test.js
+++ b/ds-bot/test/roster.test.js
@@ -150,8 +150,8 @@ for (const kind of ['main', 'copy', 'made by a Main Bot', 'made by the user']) {
} else {
bot = (await call('create-bot', { name: 'Writer', instructions })).value
}
- await until(() => sent.some(entry => entry.sessionId === bot.id))
- const greetings = sent.filter(entry => entry.sessionId === bot.id)
+ await until(() => sent.some(entry => entry.sessionId === bot.id && entry.message.source.role === 'kickoff'))
+ const greetings = sent.filter(entry => entry.sessionId === bot.id && entry.message.source.role === 'kickoff')
assert.equal(greetings.length, 1)
const { message } = greetings[0]
const text = message.content[0].text
diff --git a/ds-bot/test/update-bot.test.js b/ds-bot/test/update-bot.test.js
index 1cc74699..9287f1bd 100644
--- a/ds-bot/test/update-bot.test.js
+++ b/ds-bot/test/update-bot.test.js
@@ -32,6 +32,7 @@ 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()
+ const sent = []
Object.assign(ctx, {
llm: {
listProviders: () => [{ id: 'deepseek', name: 'DeepSeek' }],
@@ -39,7 +40,7 @@ function start() {
resolveModelInfo: async () => ({}),
},
sessionController: {
- resolveAgent: async sessionId => ({ agent: { session: { id: sessionId, seq: 1 } } }),
+ resolveAgent: async sessionId => ({ agent: { session: { id: sessionId, seq: 1 }, followup: message => sent.push({ sessionId, message }) } }),
selectModel: async () => {},
},
sessionTitle: { rename: async () => {} },
@@ -53,7 +54,7 @@ function start() {
await ctx.dispose()
rmSync(home, { recursive: true, force: true, maxRetries: 5 })
}
- return { ctx, tool, state, stop }
+ return { ctx, tool, state, sent, stop }
}
test('a Bot changes itself by leaving out bot, or by naming itself', async (t) => {
@@ -95,3 +96,21 @@ test('every Bot sees the update_bot rule in its identity section', async (t) =>
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/)
})
+
+test('an instructions change lands as a message in the Bot chat', async (t) => {
+ const { tool, sent, stop } = start()
+ t.after(stop)
+ assert.equal(await tool('update_bot', { instructions: 'Ship the fix' }, 'b2'), 'Updated Writer.')
+ // The notice goes out as a follow-up; let the queued delivery run.
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.equal(sent.length, 1)
+ assert.equal(sent[0].sessionId, 'b2')
+ const text = sent[0].message.content[0].text
+ assert.match(text, /updated your profile/)
+ assert.match(text, /Ship the fix/)
+ // A patch that changes nothing sends no message.
+ await tool('update_bot', { instructions: 'Ship the fix' }, 'b2')
+ await tool('update_bot', { color: 'red' }, 'b2')
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.equal(sent.length, 1)
+})