Skip to content

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

Archive a deleted Bot's past parts too

Fei2411dfb2911633ec
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d84242b..b553d101 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,7 @@ All notable changes to DS Bot are listed here. The format follows [Keep a Change
- In a group chat, a conversation referenced in a message reached none of the members, and a reference whose title started with a member's name called that member. Now the members who answer the message get the referenced conversation.
- In a group chat, typing `@` and a Bot's name and pressing Enter inserted a conversation reference instead of the Bot's name.
-- Deleting a Bot or group chat also removes its scheduled tasks. Before, armed tasks stayed active and kept running the deleted Session; the archive that would have stopped them was refused and the failure was silent.
+- Deleting a Bot or group chat also removes its scheduled tasks, including ones left on the Bot's earlier chat parts. Before, armed tasks stayed active and kept running the deleted Session; the archive that would have stopped them was refused and the failure was silent.
- A long conversation's fresh part keeps the Bot's model and thinking level. Before, the new part fell back to the default model.
- A provider adapter that cannot measure tokens no longer fails every turn. The context size is estimated instead, with one warning in the log.
diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.js
index f20788b1..277c1c95 100644
--- a/ds-bot/src/host/roster.js
+++ b/ds-bot/src/host/roster.js
@@ -393,8 +393,12 @@ export function install(rt) {
await archived
await rt.save()
// Same as deleteRoom: stopActivity removes the Session's armed scheduled tasks.
- await ctx.workspaceRegistry.archiveSession(current, { stopActivity: true })
- .catch(error => rt.warn('ds-bot: Bot %s not archived: %s', bot.name, error))
+ // Past parts are archived too: a part move can leave tasks on the old Session,
+ // which otherwise stays armed and invisible. Already-archived ids are a no-op.
+ for (const part of parts) {
+ await ctx.workspaceRegistry.archiveSession(part, { stopActivity: true })
+ .catch(error => rt.warn('ds-bot: Bot %s not archived: %s', bot.name, error))
+ }
}
async function bootstrap() {
diff --git a/ds-bot/test/roster.test.js b/ds-bot/test/roster.test.js
index b8011ba2..28c551b8 100644
--- a/ds-bot/test/roster.test.js
+++ b/ds-bot/test/roster.test.js
@@ -291,6 +291,33 @@ test('deleting a Bot or group chat stops its Session, so its tasks are removed',
])
})
+const TEAM_WITH_PART = {
+ version: 1,
+ mainBotIds: ['m1'],
+ revision: 2,
+ bots: {
+ m1: { id: 'm1', sessionId: 'm1', name: 'Chief', role: 'Chief of Staff', instructions: '', createdAt: 1 },
+ w1: { id: 'w1', sessionId: 'w2', name: 'Writer', role: '', instructions: '', createdAt: 2, segments: [{ sessionId: 'w1', endedAt: 3 }] },
+ },
+ rooms: {},
+ exchanges: [],
+ exchangeTurns: {},
+ questions: {},
+}
+
+test("deleting a Bot also stops its past parts' Sessions, where tasks can stay armed", async (t) => {
+ const { call, stop, archived } = start(TEAM_WITH_PART, { models: ['deepseek-v4-flash'] })
+ t.after(stop)
+ archived.length = 0
+ assert.equal((await call('delete-bot', { id: 'w1' })).ok, true)
+ // A part switch can leave armed tasks on the old Session (w1); archiving only
+ // the current one (w2) would orphan them exactly like a skipped archive.
+ assert.deepEqual(archived, [
+ ['w1', { stopActivity: true }],
+ ['w2', { stopActivity: true }],
+ ])
+})
+
test('an archive failure on delete is warned instead of passing silently', async (t) => {
const { call, stop, warnings } = start(undefined, { models: ['deepseek-v4-flash'], archiveError: new Error('archive refused') })
t.after(stop)