diff --git a/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json b/plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json index 5f3402c7..7110a907 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.42", + "version": "0.7.47", "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 81de93e3..014b3884 100644 --- a/plugins/minimax-ai/minimax-bot/README.md +++ b/plugins/minimax-ai/minimax-bot/README.md @@ -181,6 +181,13 @@ The hand-over between two Bots of a group carried the tail of the previous reply - `brief.tool.schedule` answers the other half of the same question. A user who asks whether something is running on a timer, or why their usage keeps going, gets an answer from `list_schedules`, and `delete_schedule` stops it. The line also states the limit: only this team's scheduled tasks are in that list. A schedule the Host runs elsewhere is not in it and is not under the Bot's control — a cron attached to a session from the host side showed as zero rows in the Bot's own list while it kept spending the session's quota. - Only the wording changed. No tool, no state and no limit moved: the same calls with the same arguments do the same things. +## 0.7.47 A retry that answers a merged batch delivers every input of it + +- Two messages sent together are one batch, they fail together, and the reply answers both of them. The reply carries the first input in `sourceMessageId` and the rest in `sourceMessageIds`, but the retry only cleared the first one. The others kept the verdict the failed attempt left on them. +- An input left uncertain holds every later request of the chat back. So after a retry that had worked, the user still could not send anything: the reply was there and the chat was stuck. +- A retry that answers the batch now clears every input of it. An input that carries a later verdict — a newer supplement, a cancel — still outranks the retry and is left alone. +- Only a retry that finished answers the batch. A retry that failed — or that the Host aborted, or whose retry wait was cancelled — answered nothing, so it clears nothing but the input it was made for. The other inputs of the batch keep their verdict and still hold the later requests back. + ## 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 4ba1e30b..6d44675f 100644 --- a/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs +++ b/plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs @@ -1502,12 +1502,34 @@ export class Engine { // The retry answers the same request, so the input it belongs to is delivered now. Without // this the user's line keeps the failed badge the first attempt set, and reads as "not sent" // next to a reply that did arrive. - if (result.accepted && message.sourceMessageId) { + // A batch may carry more than one input: they were sent together, they failed together, and + // this reply answers all of them. Only the first one carries `sourceMessageId`; the rest are + // in `sourceMessageIds`. Clearing just the first leaves the others uncertain, and an + // uncertain line holds every later request back. + const answered = message.sourceMessageIds?.length + ? message.sourceMessageIds + : message.sourceMessageId + ? [message.sourceMessageId] + : []; + if (result.accepted && answered.length) { const history = await this.store.getMessages(chatId); - const input = history.find((m) => m.id === message.sourceMessageId); - // Only a line that still carries the first attempt's verdict: a later state (a newer - // supplement, a cancel) outranks this retry and must not be overwritten. - if (input && (input.dispatchState === 'failed' || input.dispatchState === 'uncertain')) { + const inputs = history.filter((m) => answered.includes(m.id)); + // `accepted` only says the Host took the turn: a turn that then failed is accepted too. + // Such a retry has answered nothing, so it may not clear the failure markers of the + // whole batch — an uncertain input holds the later requests back, and that is the + // point. A failed retry settles the input it was made for, as it always did. + // + // The gate is "the turn finished", not "no error": a turn the Host aborted, and a + // retry wait that was cancelled, both end as `aborted` with `accepted` still true. + // Neither answered anything, so neither may speak for the rest of the batch. + const finished = result.status === 'done'; + const settled = finished + ? inputs + : inputs.filter((input) => input.id === (message.sourceMessageId ?? answered[0])); + for (const input of settled) { + // Only a line that still carries the first attempt's verdict: a later state (a newer + // supplement, a cancel) outranks this retry and must not be overwritten. + if (input.dispatchState !== 'failed' && input.dispatchState !== 'uncertain') continue; await this.store.updateMessage(chatId, input.id, { dispatchState: 'delivered' }); this.broadcast({ type: 'message.upsert', chatId, message: input }); } diff --git a/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs b/plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs index 63e7bd6d..a2cab5af 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.42' }, + serverInfo: { name: 'minimax-bot', version: '0.7.47' }, instructions: t('mcp.instructions'), }; break; diff --git a/plugins/minimax-ai/minimax-bot/package.json b/plugins/minimax-ai/minimax-bot/package.json index 56a3a5ed..a2a32bc2 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.42", + "version": "0.7.47", "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..82bf3946 100644 --- a/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs +++ b/plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs @@ -1457,6 +1457,115 @@ test('a successful retry marks the request it answered as delivered', async (t) await store.writeChain; }); +test('a successful retry marks every input of a merged batch as delivered', async (t) => { + const { store, engine } = await fixture(t); + const bot = store.state.bots[0]; + const chatId = `bot:${bot.id}`; + engine.agent = { async run(input, options) { + return { ...started(input, options, 'merged-reply'), status: 'finished', text: 'The answer' }; + } }; + // Two inputs were sent together, so they failed together and the reply answers both of them. + // Only the first carries sourceMessageId; the second is in sourceMessageIds. + const first = await store.appendMessage(chatId, { + role: 'user', text: 'Do the first thing', clientMessageId: 'merged-1', + clientMessageHash: engine.userMessageFingerprint('Do the first thing', []), dispatchState: 'failed', + }); + const second = await store.appendMessage(chatId, { + role: 'user', text: 'Do the second thing', clientMessageId: 'merged-2', + clientMessageHash: engine.userMessageFingerprint('Do the second thing', []), dispatchState: 'failed', + }); + const failed = await store.appendMessage(chatId, { + role: 'bot', botId: bot.id, text: '', status: 'error', + sourceMessageId: first.id, sourceMessageIds: [first.id, second.id], + retryable: true, retryInput: 'Do the first thing', errorCode: 'agent_unavailable', + }); + await store.writeChain; + + await engine.retryMessage(chatId, failed.id); + await until(() => idle(engine)); + await new Promise((resolve) => setTimeout(resolve, 60)); + + // The retry answered both inputs, so both of them are delivered now. + const history = await store.getMessages(chatId); + assert.equal(history.find((message) => message.id === first.id).dispatchState, 'delivered'); + assert.equal(history.find((message) => message.id === second.id).dispatchState, 'delivered'); + engine.dispose(); + await store.writeChain; +}); + +test('a failed retry leaves the rest of a merged batch uncertain', async (t) => { + const { store, engine } = await fixture(t); + const bot = store.state.bots[0]; + const chatId = `bot:${bot.id}`; + engine.agent = { async run(input, options) { + // The Host took the turn and then lost it: the reply is an error, but the turn was accepted. + started(input, options, 'merged-failed-reply'); + throw Object.assign(new Error('Unobserved turn'), { code: 'AGENT_OUTCOME_UNKNOWN', retryable: false }); + } }; + const first = await store.appendMessage(chatId, { + role: 'user', text: 'Do the first thing', clientMessageId: 'merged-fail-1', + clientMessageHash: engine.userMessageFingerprint('Do the first thing', []), dispatchState: 'uncertain', + }); + const second = await store.appendMessage(chatId, { + role: 'user', text: 'Do the second thing', clientMessageId: 'merged-fail-2', + clientMessageHash: engine.userMessageFingerprint('Do the second thing', []), dispatchState: 'uncertain', + }); + const failed = await store.appendMessage(chatId, { + role: 'bot', botId: bot.id, text: '', status: 'error', + sourceMessageId: first.id, sourceMessageIds: [first.id, second.id], + retryable: true, retryInput: 'Do the first thing', errorCode: 'agent_unavailable', + }); + await store.writeChain; + + await engine.retryMessage(chatId, failed.id); + await until(() => idle(engine)); + await new Promise((resolve) => setTimeout(resolve, 60)); + + // The retry failed, so it answered nothing: the second input keeps its verdict and still + // holds the later requests back. Only the input the retry was made for is settled. + const history = await store.getMessages(chatId); + assert.equal(history.find((message) => message.id === first.id).dispatchState, 'delivered'); + assert.equal(history.find((message) => message.id === second.id).dispatchState, 'uncertain'); + engine.dispose(); + await store.writeChain; +}); + +test('an aborted retry leaves the rest of a merged batch uncertain', async (t) => { + const { store, engine } = await fixture(t); + const bot = store.state.bots[0]; + const chatId = `bot:${bot.id}`; + engine.agent = { async run(input, options) { + // The Host took the turn and then aborted it. `accepted` is true and the status is + // `aborted`, not `error` — the turn answered nothing all the same. + const ids = started(input, options, 'merged-aborted-reply'); + return { ...ids, status: 'aborted' }; + } }; + const first = await store.appendMessage(chatId, { + role: 'user', text: 'Do the first thing', clientMessageId: 'merged-abort-1', + clientMessageHash: engine.userMessageFingerprint('Do the first thing', []), dispatchState: 'uncertain', + }); + const second = await store.appendMessage(chatId, { + role: 'user', text: 'Do the second thing', clientMessageId: 'merged-abort-2', + clientMessageHash: engine.userMessageFingerprint('Do the second thing', []), dispatchState: 'uncertain', + }); + const failed = await store.appendMessage(chatId, { + role: 'bot', botId: bot.id, text: '', status: 'error', + sourceMessageId: first.id, sourceMessageIds: [first.id, second.id], + retryable: true, retryInput: 'Do the first thing', errorCode: 'agent_unavailable', + }); + await store.writeChain; + + await engine.retryMessage(chatId, failed.id); + await until(() => idle(engine)); + await new Promise((resolve) => setTimeout(resolve, 60)); + + const history = await store.getMessages(chatId); + assert.equal(history.find((message) => message.id === first.id).dispatchState, 'delivered'); + assert.equal(history.find((message) => message.id === second.id).dispatchState, 'uncertain'); + engine.dispose(); + await store.writeChain; +}); + test('a group round whose members pass does not report a pass as its outcome', async (t) => { const { store, engine } = await fixture(t); const { a, chatId } = groupFixture(store);