diff --git a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json index 370cee81..67ce19d7 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.40", + "version": "0.7.46", "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 651f680a..670b391c 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.46 A finished reply is not left uncertain after a restart + +- A request is marked `processing` before its turn runs. If the process stops after the reply is written but before the inbox writes the delivery verdict, restart used to see the reply and mark the request `uncertain` — without looking at the reply's status. A finished reply therefore left the chat held, and every later request waited behind it. +- The retry path already had the narrower rule: only an interrupted reply, a streaming reply, or `AGENT_OUTCOME_UNKNOWN` makes the outcome uncertain. Restart recovery now uses that same rule. A reply that finished is proof that the request was delivered; no reply still means the request never reached the Host. +- The rule lives in one exported predicate so the retry path and restart recovery cannot drift apart again. + ## 0.7.40 A value that is not there is left out, not refused - The reply mode of a group and the kind of a scheduled task are checked against the values the catalogue offers, so a value that is not one of them is refused instead of quietly becoming another one. A value that is not there at all was refused too, when it arrived as null: many models write an optional field they did not fill in as null, and the call failed with "reply_mode must be one of: admin, all". diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs index 33ffe93b..c0d21e43 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs @@ -8,7 +8,7 @@ import { MemoryError, storageBudget } from './memory.mjs'; import { selectMemoryContext } from './memory-context.mjs'; import { UserInbox } from './user-inbox.mjs'; import { TaskDispatcher } from './task-dispatcher.mjs'; -import { modelKey, newId, withEffort } from './store.mjs'; +import { modelKey, newId, replyOutcomeUnknown, withEffort } from './store.mjs'; import { CONVERGE_MARK, CONTEXT_BLOCK_END, CONTEXT_BLOCK_MARK, handoverRequested, handoverSummary, hopLimit, neutralizeMarks, renderHandover, roundEntries } from './relay-guard.mjs'; import { appendNote, notesEnabled, renderNote } from './group-note.mjs'; @@ -1187,8 +1187,7 @@ export class Engine { if (fingerprint !== request.fingerprint) throw new EngineError('invalid', t('err.messageIdConflict')); const admitted = this.inbox.has(existing.id) || [...this.tickets].some((ticket) => ticket.chatId === chatId && ticket.sourceMessageId === existing.id); const replies = messages.filter((message) => message.sourceMessageId === existing.id || message.sourceMessageIds?.includes(existing.id)); - if (!admitted && (existing.dispatchState === 'uncertain' || replies.some((message) => - message.status === 'interrupted' || message.status === 'streaming' || message.errorCode === 'AGENT_OUTCOME_UNKNOWN'))) { + if (!admitted && (existing.dispatchState === 'uncertain' || replies.some(replyOutcomeUnknown))) { await this.store.updateMessage(chatId, existing.id, { dispatchState: 'uncertain' }); this.broadcast({ type: 'message.upsert', chatId, message: existing }); throw new EngineError('delivery_uncertain', t('err.messageDeliveryUncertain')); diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs index a6473f79..2959b5ff 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.40' }, + serverInfo: { name: 'minimax-bot', version: '0.7.46' }, instructions: t('mcp.instructions'), }; break; diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs index be21039d..ad171b33 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs @@ -9,6 +9,11 @@ import { ReactionError, validateReaction } from './reactions.mjs'; export const DEFAULT_MESSAGE_PAGE_SIZE = 100; export const MAX_MESSAGE_PAGE_SIZE = 500; + +/** A reply whose outcome the process could not confirm after a restart. */ +export function replyOutcomeUnknown(reply) { + return reply?.status === 'interrupted' || reply?.status === 'streaming' || reply?.errorCode === 'AGENT_OUTCOME_UNKNOWN'; +} /** Octopus gradient palettes; the client owns the actual colors. */ export const BOT_COLORS = [ 'ocean', 'sky', 'teal', 'green', 'lime', 'yellow', 'orange', 'red', 'pink', 'violet', 'indigo', 'graphite', @@ -511,8 +516,12 @@ export class Store { } } if (message.role === 'user' && ['adjusting', 'processing'].includes(message.dispatchState)) { + const replies = list.filter((reply) => reply.sourceMessageId === message.id || reply.sourceMessageIds?.includes(message.id)); + // A reply that finished is proof that the request was delivered, even if the process + // died before the inbox could write that verdict. Only a reply whose outcome is not + // known stays uncertain; this is the same rule the retry path uses. message.dispatchState = message.dispatchState === 'adjusting' ? 'held' - : list.some((reply) => reply.sourceMessageId === message.id || reply.sourceMessageIds?.includes(message.id)) ? 'uncertain' : 'pending'; + : replies.some(replyOutcomeUnknown) ? 'uncertain' : replies.length ? 'delivered' : 'pending'; message.dispatchRevision = (message.dispatchRevision ?? 0) + 1; dirty = true; } diff --git a/plugins/minimax-ai/minimax-bot/package.json b/plugins/minimax-ai/minimax-bot/package.json index e799ef2e..dc9df08e 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.40", + "version": "0.7.46", "private": true, "type": "module", "mcode": { diff --git a/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs b/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs index c7e82e3b..ccde4b16 100644 --- a/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs +++ b/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs @@ -648,6 +648,38 @@ test('an interrupted associated assistant is reported as uncertain, and legacy m await restored.writeChain; }); +test('a finished associated assistant is delivered after restart, so later requests run', async (t) => { + const { dir, store, memory, engine } = await fixture(t); + const bot = store.state.bots[0]; + const chatId = `bot:${bot.id}`; + const user = await store.appendMessage(chatId, { + role: 'user', text: 'Finish this', clientMessageId: 'finished-1', + clientMessageHash: engine.userMessageFingerprint('Finish this', []), dispatchState: 'processing', + }); + await store.appendMessage(chatId, { + role: 'bot', botId: bot.id, sourceMessageId: user.id, status: 'done', text: 'Finished answer', + }); + await store.writeChain; + engine.dispose(); + + // The process died after the reply was written but before the inbox could mark the request + // delivered. The finished reply is proof that the request made it to the Host. + const restored = new Store(dir); + await restored.init(); + assert.equal((await restored.getMessages(chatId)).find((message) => message.id === user.id).dispatchState, 'delivered'); + + let runs = 0; + const reopened = new Engine({ store: restored, memory, logger: { warn() {} }, broadcast() {}, agent: { + async run(input, options) { runs += 1; return { ...started(input, options, 'after-finished'), status: 'finished', text: 'Later answer' }; }, + } }); + await reopened.sendUserMessage(chatId, 'A later request', [], 'later-1'); + await until(() => idle(reopened)); + assert.equal(runs, 1, 'the later request is not held behind a finished turn'); + assert.equal((await restored.getMessages(chatId)).find((message) => message.text === 'A later request').dispatchState, 'delivered'); + reopened.dispose(); + await restored.writeChain; +}); + test('a request whose queue died with the process is still sendable from the page', async (t) => { const { dir, store, memory, engine } = await fixture(t); const bot = store.state.bots[0];