Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/minimax-ai/minimax-bot/.minimax-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"name": "minimax-bot",
"displayName": "MiniMax Bot",
"version": "0.7.37",
"version": "0.7.38",
"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",
Expand Down
11 changes: 11 additions & 0 deletions plugins/minimax-ai/minimax-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ The hand-over between two Bots of a group carried the tail of the previous reply
- The stored name now replaces a run of dots, and a long name is cut on a whole character so an emoji is never left half-written.
- The extension is kept apart from the rest of the name and survives that cleaning, because it decides how the file is served: `photo..png` was stored as `photo_png`, so it went out as `application/octet-stream` and the Bot received a plain file instead of an image. It is stored as `photo.png` now and stays a PNG end to end.

## 0.7.38 The page tells the user when a chat is stuck and when a job was stopped

- A turn whose outcome cannot be confirmed — the process stopped while it was running, or the Host took it and never said — leaves the request marked as unknown. Every later message of that chat waits for it, on purpose: a correction must not act on a state nobody can vouch for.
- But the way out was not reachable. The page draws its continuation button on a held message and on a request a restart left stranded; a message with an unknown outcome got no button, and the continuation route answered `busy` when the chat held nothing but that one message. So a chat with a single unknown outcome had no way out at all: the user could not confirm it, could not send it again under the same id, and every new request joined the queue behind it. Restarting did not help, because the state is on disk — and a restart in the middle of a turn is what produces it.
- A message with an unknown outcome now carries the same button, and the continuation route accepts a chat that holds nothing but such a message. Confirming it does not send that turn again: the request stays marked as unknown, and the chat goes on. The requests that were waiting behind it are sent. Once confirmed, the button is gone and the line says the later messages may go on.
- The stop button of a background job had the same trouble from the other side. It asked the Host to end the turn, but the job kept the `running` state until that turn actually came back. The Host ends a turn between its steps, so a job inside a long tool call kept reading as running for a while — and to a user pressing the button, nothing had happened at all. The only thing left to try was quitting the whole app.
- The job is marked stopped the moment the stop is asked for, so the page stops reading it as running. The turn still winds down in the background; what changes is that the page tells the truth about it. The abort still goes to the same turn, and a job that was already stopped or already finished is left alone.
- Asking to let a stuck chat go now shows on the page that it took: the message says the later messages may go on, and the button is gone. A message that arrives while that is being written goes out with it, instead of waiting for a second press of the button.
- A job that was stopped and then killed by the process still leaves its turn in the usage ledger. The row is written under the job's own id, so a job that did finish is not counted twice.
- Nothing else moves: a request with an unknown outcome is still never replayed on its own, and the order of the messages around it is unchanged.

## 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.
Expand Down
10 changes: 8 additions & 2 deletions plugins/minimax-ai/minimax-bot/miniapp/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,13 @@ function userDelivery(message) {
const stranded = status === 'pending' && !sentHere.has(message.id) && !state.busy.has(message.chatId)
&& !(state.messages.get(message.chatId) ?? []).some(
(item) => item.sourceMessageId === message.id || item.sourceMessageIds?.includes(message.id));
const button = status === 'held' || stranded ? h('button', {
// A turn whose outcome is unknown holds every later message of the chat. The page has to offer
// the way out on the message that carries that state: asking from anywhere else would not show
// the user where the chat is stuck.
// Once the user has confirmed it, the asking is done: the button goes away, so the page says
// that the confirmation took effect.
const confirmed = message.continuationAcknowledged === true;
const button = status === 'held' || (status === 'uncertain' && !confirmed) || stranded ? h('button', {
type: 'button', class: 'btn sm', disabled: deliveryActions.has(key),
onclick: async (event) => {
if (deliveryActions.has(key)) return;
Expand All @@ -825,7 +831,7 @@ function userDelivery(message) {
},
}, t('delivery.resume')) : null;
return h('div', { class: 'message-delivery', role: 'status' },
h('span', null, tOr(`delivery.${status}`, undefined, '')), button);
h('span', null, confirmed && status === 'uncertain' ? t('delivery.uncertainConfirmed') : tOr(`delivery.${status}`, undefined, '')), button);
}
const deliveryActions = new Set();

Expand Down
2 changes: 2 additions & 0 deletions plugins/minimax-ai/minimax-bot/miniapp/client/strings-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
"delivery.adjusting": "正在调整…",
"delivery.held": "尚未确认可以继续。请先检查完整会话,再继续处理补充。",
"delivery.uncertain": "处理结果待确认,请查看完整会话。",
"delivery.uncertainConfirmed": "处理结果仍待确认,已确认继续后面的消息。",
"delivery.cancelled": "已取消处理",
"delivery.failed": "未送达,请查看回复中的错误提示。",
"delivery.resume": "继续处理补充",
Expand Down Expand Up @@ -302,6 +303,7 @@ export default {
"delivery.adjusting": "Adjusting…",
"delivery.held": "Continuation needs confirmation. Check the full session before continuing with follow-ups.",
"delivery.uncertain": "Outcome unknown. Check the full session.",
"delivery.uncertainConfirmed": "Outcome still unknown; you confirmed to go on with the later messages.",
"delivery.cancelled": "Cancelled",
"delivery.failed": "Not delivered. Check the reply for details.",
"delivery.resume": "Continue with follow-ups",
Expand Down
7 changes: 7 additions & 0 deletions plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,13 @@ export class Engine {
}
if (!HELPER_ACTIVE.has(helper.status)) return { stopped: false, status: helper.status };
run.stoppedBy = who;
// The Host ends a turn between its steps, so a run that is inside a long tool call keeps
// going for a while after the abort. The job is not working any more, and the page has to
// say so at once: a stop button that leaves the row reading "running" looks like it did
// nothing, and the only thing left to try is quitting the whole app.
helper.status = 'stopped';
void this.store.save().catch((error) => this.logger.warn('minimax_bot.helper_stop_save_failed', { helperId: helper.id, code: error?.code ?? 'unknown' }));
this.broadcastHelpers();
run.controller.abort();
return { stopped: true, status: 'stopped' };
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/minimax-ai/minimax-bot/miniapp/node/mcp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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.37' },
serverInfo: { name: 'minimax-bot', version: '0.7.38' },
instructions: t('mcp.instructions'),
};
break;
Expand Down
18 changes: 18 additions & 0 deletions plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@ export class Store {
// A queued job never reached the model; a running one had already called it.
attempts: wasQueued ? 0 : 1,
});
} else if (helper.status === 'stopped') {
// The stop was asked for and the job was marked stopped at once, but the turn it was in
// writes its ledger row when it winds down. If the process was killed in between, that
// row is missing: a job the user stopped still spent a turn. The row is written under the
// job's own id, so a job that did finish is not counted twice.
await this.recordUsageOnce({
ts: helper.startedAt ?? helper.createdAt ?? helper.endedAt ?? Date.now(),
turnId: helper.id,
botId: helper.botId,
botName: this.getBot(helper.botId)?.name ?? '',
chatId: helper.chatId,
kind: 'helper-run',
status: 'aborted',
durationMs: null,
chars: 0,
tools: helper.turnTools ?? 0,
attempts: helper.startedAt ? 1 : 0,
});
}
}
this.state.taskBatches = Array.isArray(this.state.taskBatches) ? this.state.taskBatches : [];
Expand Down
30 changes: 23 additions & 7 deletions plugins/minimax-ai/minimax-bot/miniapp/node/user-inbox.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,41 @@ export class UserInbox {

async resumeHeld(chatId) {
// Only resend supplements that never started; an uncertain original request is never replayed.
const history = await this.engine.store.getMessages(chatId);
const held = history.filter((message) => {
/** The messages of a list that can be sent again. */
const recoverableOf = (list) => list.filter((message) => {
if (message.role !== 'user' || this.has(message.id)) return false;
if (message.dispatchState === 'held') return true;
// A restart leaves an accepted request `pending` with the queue that owned it gone. It is
// recoverable on the same proof the retry path uses: no reply and no durable assistant
// placeholder means the request never reached the Host.
return message.dispatchState === 'pending'
&& !history.some((item) => item.sourceMessageId === message.id || item.sourceMessageIds?.includes(message.id));
&& !list.some((item) => item.sourceMessageId === message.id || item.sourceMessageIds?.includes(message.id));
});
if (!held.length || this.busy(chatId) || [...this.engine.tickets].some((ticket) => ticket.chatId === chatId)) {
/** The same list, read fresh: it changes while the disk is written. */
const recoverable = async () => recoverableOf(await this.engine.store.getMessages(chatId));
const history = await this.engine.store.getMessages(chatId);
const held = await recoverable();
// A turn whose outcome is unknown holds every later message of the chat, so a chat that has
// one is stuck until the user says what to do with it. Asking is the only way out, so the
// asking must work even when there is nothing to send again: the unknown turn is confirmed
// as seen, and the chat goes on.
const uncertainIds = history.filter((message) => message.role === 'user' && message.dispatchState === 'uncertain').map((message) => message.id);
if ((!held.length && !uncertainIds.length) || this.busy(chatId) || [...this.engine.tickets].some((ticket) => ticket.chatId === chatId)) {
throw new this.ErrorType('busy', t('err.messageAlreadyProcessing'));
}
const bot = chatId.startsWith('bot:') ? this.engine.store.getBot(chatId.slice(4)) : undefined;
const group = chatId.startsWith('group:') ? this.engine.store.getGroup(chatId.slice(6)) : undefined;
if (!bot && !group) throw new this.ErrorType('not_found', t('err.chatMissing'));
const uncertainIds = history.filter((message) => message.role === 'user' && message.dispatchState === 'uncertain').map((message) => message.id);
await this.engine.store.updateMessages(chatId, uncertainIds, { continuationAcknowledged: true });
const heldIds = new Set(held.map((message) => message.id));
// Confirming the unknown turn is not replaying it: it is the user saying they have seen it.
// The turn itself is never sent again.
const acknowledged = await this.engine.store.updateMessages(chatId, uncertainIds, { continuationAcknowledged: true });
// The page has to hear about it: without this the button stays on the message that was just
// confirmed, and the user cannot tell whether asking did anything.
for (const message of acknowledged) this.engine.broadcast({ type: 'message.upsert', chatId, message });
// Read the list again: a message that arrived while the confirmation was being written was
// held too, and it belongs to this continuation rather than to the next button press.
const heldNow = await recoverable();
const heldIds = new Set(heldNow.map((message) => message.id));
// Re-check inside the write: a retry carrying the same clientMessageId can enqueue the message
// while this call waits for the disk, and a message that moved on must not be sent a second
// time. Only the state this call actually reached is still recoverable.
Expand Down
2 changes: 1 addition & 1 deletion plugins/minimax-ai/minimax-bot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minimax-bot",
"version": "0.7.37",
"version": "0.7.38",
"private": true,
"type": "module",
"mcode": {
Expand Down
14 changes: 13 additions & 1 deletion plugins/minimax-ai/minimax-bot/tests/client-reliability.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -844,4 +844,16 @@ test('the background task strip keeps the official one line rows and folds a lon
emit({ type: 'helpers.changed', helpers });
await settle();
assert.match(strip.querySelector('.helper-more').textContent, /4 more tasks/, 'the queue starts folded again');
});
});
test('an unknown outcome offers the way out, so the chat is not stuck for good', async () => {
// A turn whose outcome is unknown holds every later message of the chat. The page has to
// offer the way out on the message that carries that state.
const unknown = message('msg_unknown', 'Possibly already executed', { role: 'user', dispatchState: 'uncertain' });
await reset([unknown]);
assert.match(document.querySelector('.message-delivery').textContent, /Outcome unknown/);
const button = document.querySelector('.message-delivery button');
assert.notEqual(button, null, 'the message that holds the chat offers the continuation');
route = ({ path }) => path.endsWith('/resume-pending') ? response({ ok: true }) : undefined;
button.click(); await settle();
assert.equal(calls.filter((call) => call.path.endsWith('/resume-pending')).length, 1);
});
Loading