diff --git a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json index 915018bd..3fdf839a 100644 --- a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json +++ b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "minimax-bot", "displayName": "MiniMax Bot", - "version": "0.7.39", + "version": "0.7.41", "description": "Turn MiniMax Code into an always-on team of Bots. A Chief Bot helps you build the team; in group chats the admin answers and @mentions hand work to other members. Every Bot has its own octopus avatar and memory, with scheduled tasks and usage stats.", "author": "MiniMax Code", "icon": "icon.png", diff --git a/plugins/minimax-ai/minimax-bot/README.md b/plugins/minimax-ai/minimax-bot/README.md index c022ed8c..da9699f3 100644 --- a/plugins/minimax-ai/minimax-bot/README.md +++ b/plugins/minimax-ai/minimax-bot/README.md @@ -161,6 +161,12 @@ The hand-over between two Bots of a group carried the tail of the previous reply - `` reached the next Bot whole: the closing tag of the block the plugin writes around the context. The words around it were kept, as they are for every other spelling. - The text is now walked by code point, so a character outside the Basic Multilingual Plane is read as the one character it is. The tag characters are named as well, because some of the slots in that block are not assigned in every Unicode version and are therefore not caught by the general categories. +## 0.7.41 A finished background job is not left reading as running + +- A background job publishes its status to the page through one broadcast, and that broadcast came after the write that closed the job out. A write that fails there — no space, a read-only disk — skipped the broadcast, so the page kept the last status it had been told, which is `running`. The job is already final in memory, and it never runs again, so nothing else would ever correct the row: the spinner stayed for good, and the only thing left to do was restart. +- The status is now published before that write, and the write's failure is logged instead of ending the turn. The report that posts the job's outcome into its chat had the same shape and is fixed the same way, so a disk that fails once no longer costs the page the job's ending or the chat its note. +- What is on disk is unchanged: the write still happens before the report, and the status it writes is the same one. Only the order of that one broadcast and the handling of a failed write changed. + ## 0.7.10 Optional group notes - A group can keep a note of what it said. After every round the group records the closing lines of the replies, and every Bot of the group gets that record in its standing brief. diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs index 33ffe93b..5415b41b 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs @@ -1981,8 +1981,16 @@ export class Engine { } if (this.disposed) return; this.trimHelpers(); - await this.store.save(); + // Tell the page the job is over before the write, not after it. The status is already final + // in memory, and a write that fails is no reason to leave the row reading "running" for good: + // the job never runs again, so nothing else would ever correct it. The write itself still + // has to happen before the report goes out, and a failure still has to be reported. this.broadcastHelpers(); + try { + await this.store.save(); + } catch (error) { + this.logger.warn('minimax_bot.helper_final_save_failed', { helperId: helper.id, code: error?.code ?? 'unknown' }); + } await this.deliverHelperReport(helper, run.stoppedBy); } @@ -2005,8 +2013,14 @@ export class Engine { this.broadcast({ type: 'message.upsert', chatId, message: note }); this.broadcastSummary(chatId); helper.resultMessageId = note.id; - await this.store.save(); + // Same reason as the status broadcast above: the note is already in the chat and the status + // is already final, so a write that fails must not keep the page from hearing either. this.broadcastHelpers(); + try { + await this.store.save(); + } catch (error) { + this.logger.warn('minimax_bot.helper_report_save_failed', { helperId: helper.id, code: error?.code ?? 'unknown' }); + } if (helper.parentTaskId) { await this.tasks.receiveDependency(helper.parentTaskId, helper.id, this.tasks.helperReport(helper)); return; diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs index 5e0c520a..816891ef 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs @@ -662,7 +662,7 @@ export function createMcpHandler({ team, engine }) { result = { protocolVersion: PROTOCOL_VERSIONS.includes(requested) ? requested : PROTOCOL_VERSIONS[0], capabilities: { tools: { listChanged: false } }, - serverInfo: { name: 'minimax-bot', version: '0.7.39' }, + serverInfo: { name: 'minimax-bot', version: '0.7.41' }, instructions: t('mcp.instructions'), }; break; diff --git a/plugins/minimax-ai/minimax-bot/package.json b/plugins/minimax-ai/minimax-bot/package.json index 56878589..27a00780 100644 --- a/plugins/minimax-ai/minimax-bot/package.json +++ b/plugins/minimax-ai/minimax-bot/package.json @@ -1,6 +1,6 @@ { "name": "minimax-bot", - "version": "0.7.39", + "version": "0.7.41", "private": true, "type": "module", "mcode": { diff --git a/plugins/minimax-ai/minimax-bot/tests/helper-usage.test.mjs b/plugins/minimax-ai/minimax-bot/tests/helper-usage.test.mjs index e317f323..33932912 100644 --- a/plugins/minimax-ai/minimax-bot/tests/helper-usage.test.mjs +++ b/plugins/minimax-ai/minimax-bot/tests/helper-usage.test.mjs @@ -262,3 +262,54 @@ test('a job stopped and then killed still leaves its turn in the ledger', async assert.equal(background.status, 'aborted'); assert.equal(background.turnId, store.state.helpers[0].id); }); + +test('a background job whose closing write fails still stops reading as running', async (t) => { + const { store, engine } = await fixture(t); + const bot = { id: 'bot_a', name: 'Alice', role: 'Writer' }; + store.state.bots = [bot]; + const chatId = `bot:${bot.id}`; + const helperDone = deferred(); + const seen = []; + const calls = []; + engine.agent = { async run(input, options) { + calls.push(input.text); + const ids = { sessionId: `session-${calls.length}`, turnId: `turn-${calls.length}` }; + options.onEvent({ type: 'turn.started', ...ids }); + if (input.text.startsWith(HELPER_PROMPT)) { + await helperDone.promise; + return { ...ids, status: 'finished', text: 'BACKGROUND_ANSWER' }; + } + if (input.text.endsWith('START_BACKGROUND')) { + await engine.startHelper(bot, { task: 'Look this up' }); + return { ...ids, status: 'finished', text: 'Started' }; + } + return { ...ids, status: 'finished', text: 'Relay' }; + } }; + // The panel is told the job's status through these broadcasts, and nothing else updates it. + const realBroadcastHelpers = engine.broadcastHelpers.bind(engine); + engine.broadcastHelpers = (...args) => { + realBroadcastHelpers(...args); + seen.push(...(store.state.helpers ?? []).map((helper) => helper.status)); + }; + + await engine.runBotTurn({ bot, chatId, text: 'START_BACKGROUND', kind: 'private' }); + await until(() => store.state.helpers[0]?.status === 'running'); + // The job finishes, and the write that closes it out fails. Only that write fails: the ones + // before it still have to land, or the job never reaches its final state at all and the test + // would be measuring something else. + const realSave = store.save.bind(store); + store.save = async (...args) => { + const settled = (store.state.helpers ?? []).some((helper) => helper.status === 'done' || helper.status === 'stopped'); + if (settled) throw Object.assign(new Error('no space left'), { code: 'ENOSPC' }); + return realSave(...args); + }; + helperDone.resolve(); + // The job reaches its final state in memory; what is missing is the page hearing it. + await until(() => store.state.helpers[0]?.status === 'done'); + await until(() => seen.length >= 3); + + assert.equal(store.state.helpers[0].status, 'done'); + assert.ok(seen.includes('done'), `the page was never told the job finished: saw ${seen.join(',')}`); + // The failure is still reported rather than swallowed. + assert.ok(calls.length >= 2); +});