Skip to content

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

Gate and render the profile-update notice

Fei2411a04dcd0b206e
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 0c7d9bf8..0fb2dc92 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -629,6 +629,7 @@ var ZH = {
"{name} was cut off by a restart and picked its work back up": "{name} 的工作被重启打断,已经接着做",
"{name} was cut off by a restart again and stopped": "{name} 的工作又被重启打断,已停下",
"Picked up its work after a restart": "重启后接着做之前的工作",
+ "Profile updated": "资料已更新",
"Asked to make the tool call it wrote as text": "工具调用被写成了文字,已让它重新调用",
"A Bot": "一个 Bot",
"{name} is waiting for your approval": "{name} 等你批准",
@@ -7597,6 +7598,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
if (source.handoff === true) return roster.roomsById[sessionId] ? null : (0, import_react12.createElement)(EarlierParts, { sessionId, roster, actions });
if (source.role === "kickoff" || source.role === "room") return null;
if (source.role === "secret" || deferred) return null;
+ if (source.role === "update") return (0, import_react12.createElement)("div", { className: "bt-event" }, t("Profile updated"));
if (source.role === "post") {
if (source.logged !== void 0) return null;
if (source.failed !== void 0 || source.resumed === true || source.stopped === true || source.done === true) return null;
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 81377b96..9bc9d1ce 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -586,6 +586,9 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl
if (source.role === 'kickoff' || source.role === 'room') return null
// The secret card itself shows what the user did; the note to the Bot stays out.
if (source.role === 'secret' || deferred) return null
+ // A profile notice is the user's edit landing in the Bot's chat, not a peer
+ // message: show it as an event, with no exchange to open.
+ if (source.role === 'update') return h('div', { className: 'bt-event' }, t('Profile updated'))
if (source.role === 'post') {
// A post logged into a running round already shows there, not again as a trigger.
if (source.logged !== undefined) return null
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index 3eb93caa..4b49aae4 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -574,6 +574,7 @@ const ZH = {
'{name} was cut off by a restart and picked its work back up': '{name} 的工作被重启打断,已经接着做',
'{name} was cut off by a restart again and stopped': '{name} 的工作又被重启打断,已停下',
'Picked up its work after a restart': '重启后接着做之前的工作',
+ 'Profile updated': '资料已更新',
'Asked to make the tool call it wrote as text': '工具调用被写成了文字,已让它重新调用',
'A Bot': '一个 Bot',
'{name} is waiting for your approval': '{name} 等你批准',
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index 9ad04560..4be4f410 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -318,7 +318,11 @@ export function install(rt) {
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) {
+ // 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) {
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/test/update-bot.test.js b/ds-bot/test/update-bot.test.js
index 9287f1bd..9303414c 100644
--- a/ds-bot/test/update-bot.test.js
+++ b/ds-bot/test/update-bot.test.js
@@ -28,9 +28,9 @@ const TEAM = {
questions: {},
}
-function start() {
+function start(team = TEAM) {
const home = mkdtempSync(join(tmpdir(), 'ds-bot-update-'))
- if (!existsSync(join(home, 'state.json'))) writeFileSync(join(home, 'state.json'), JSON.stringify(TEAM))
+ if (!existsSync(join(home, 'state.json'))) writeFileSync(join(home, 'state.json'), JSON.stringify(team))
const ctx = fakeContext()
const sent = []
Object.assign(ctx, {
@@ -47,14 +47,18 @@ function start() {
sessions: { flush: async () => {} },
workspaceRegistry: { archiveSession: async () => {} },
})
+ let route
+ const register = ctx.connection.fetch.register
+ ctx.connection.fetch.register = (options) => { route = options; return register(options) }
apply(ctx, { home })
const tool = (name, args, sessionId) => ctx.registeredTools.get(name).execute(args, { agent: { id: sessionId } })
+ const call = async (endpoint, payload) => (await route.fetch(new Request('http://localhost/api/bot', { method: 'POST', body: JSON.stringify({ endpoint, payload }) }))).json()
const state = () => JSON.parse(readFileSync(join(home, 'state.json'), 'utf8'))
const stop = async () => {
await ctx.dispose()
rmSync(home, { recursive: true, force: true, maxRetries: 5 })
}
- return { ctx, tool, state, sent, stop }
+ return { ctx, tool, call, state, sent, stop }
}
test('a Bot changes itself by leaving out bot, or by naming itself', async (t) => {
@@ -98,9 +102,9 @@ test('every Bot sees the update_bot rule in its identity section', async (t) =>
})
test('an instructions change lands as a message in the Bot chat', async (t) => {
- const { tool, sent, stop } = start()
+ const { call, tool, sent, stop } = start()
t.after(stop)
- assert.equal(await tool('update_bot', { instructions: 'Ship the fix' }, 'b2'), 'Updated Writer.')
+ assert.equal((await call('update-bot', { id: 'b2', instructions: 'Ship the fix' })).ok, true)
// 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)
@@ -109,8 +113,24 @@ test('an instructions change lands as a message in the Bot chat', async (t) => {
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 call('update-bot', { id: 'b2', instructions: 'Ship the fix' })
+ await call('update-bot', { id: 'b2', color: 'red' })
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.
+ assert.equal(await tool('update_bot', { instructions: 'Own fix' }, 'b2'), 'Updated Writer.')
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.equal(sent.length, 1)
+})
+
+test('a Bot whose greeting is still held gets no notice before its model pick', async (t) => {
+ const team = JSON.parse(JSON.stringify(TEAM))
+ delete team.bots.b3.model
+ team.bots.b3.kickoff = { text: 'Greet the user.', from: null }
+ const { call, sent, stop } = start(team)
+ t.after(stop)
+ assert.equal((await call('update-bot', { id: 'b3', instructions: 'Ship the fix' })).ok, true)
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.equal(sent.length, 0)
})