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.31",
"version": "0.7.32",
"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
5 changes: 5 additions & 0 deletions plugins/minimax-ai/minimax-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ The hand-over between two Bots of a group carried the tail of the previous reply
- The page now offers the same **Continue with follow-ups** button for it, and the resume route accepts it, so the request can be sent again. Nothing is replayed on its own: the turn may already have run tools before the process stopped, so sending it again stays the user's decision.
- A request whose reply had already started is unchanged, and a request this page has just sent never offers to resume itself.

## 0.7.32 A failed write is reported instead of taking the process down

- Two writes the plugin fires and forgets had nothing to catch their failure: the session id recorded when a turn starts, and the scheduled-task scan that runs every 30 seconds. A failed write there became an unhandled rejection, and the Host fails the whole Mini App process on one of those — so a disk that would not take a write took every running turn with it, and the scheduled task kept retrying every 30 seconds.
- Both now report the failure through the plugin log, the way the task save next to one of them already did. The turn carries on, and the scan keeps running.

## 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: 7 additions & 3 deletions plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ export class Engine {
task.sessionId = event.sessionId;
void this.tasks.save().catch((error) => this.logger.warn('minimax_bot.task_save_failed', { taskId: task.id, code: error?.code ?? 'unknown' }));
}
void this.store.setSession(chatId, bot.id, { sessionId: event.sessionId });
void this.store.setSession(chatId, bot.id, { sessionId: event.sessionId })
.catch((error) => this.logger.warn('minimax_bot.session_save_failed', { chatId, code: error?.code ?? 'unknown' }));
flush(true);
break;
case 'text.delta':
Expand Down Expand Up @@ -1624,9 +1625,12 @@ export class Engine {

// ------------------------------------------------------------------ schedules
startScheduler() {
this.scheduleTimer = setInterval(() => void this.tickSchedules(), 30_000);
// A failed save inside the tick must not become an unhandled rejection: the Host turns one of
// those into a failed Mini App process, so a bad disk would take every running turn with it.
const tick = () => this.tickSchedules().catch((error) => this.logger.warn('minimax_bot.schedule_tick_failed', { code: error?.code ?? 'unknown' }));
this.scheduleTimer = setInterval(() => void tick(), 30_000);
this.scheduleTimer.unref?.();
void this.tickSchedules();
void tick();
}

async tickSchedules() {
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.31' },
serverInfo: { name: 'minimax-bot', version: '0.7.32' },
instructions: t('mcp.instructions'),
};
break;
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.31",
"version": "0.7.32",
"private": true,
"type": "module",
"mcode": {
Expand Down
68 changes: 67 additions & 1 deletion plugins/minimax-ai/minimax-bot/tests/engine-reliability.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import { mkdtemp, rm } from 'node:fs/promises';
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
Expand Down Expand Up @@ -1319,3 +1319,69 @@ test('a resume that loses the race to a same-id retry does not send the request
engine.dispose();
await store.writeChain;
});

test('a failed session write during a turn is reported, not thrown as an unhandled rejection', async (t) => {
const { dir, store, memory } = await fixture(t);
const bot = store.state.bots[0];
const chatId = `bot:${bot.id}`;
const rejected = [];
const onRejection = (error) => rejected.push(error);
process.on('unhandledRejection', onRejection);
t.after(() => process.removeListener('unhandledRejection', onRejection));

const logged = [];
const engine = new Engine({ store, memory, broadcast() {}, retryDelaysMs: [], logger: { warn: (key) => logged.push(key) }, agent: {
async run(input, options) {
options.onEvent({ type: 'turn.started', sessionId: 'host-session', turnId: 'turn-1' });
return { sessionId: 'host-session', turnId: 'turn-1', status: 'finished', text: 'Done' };
},
} });
// Every state write fails from here on.
const statePath = join(dir, 'state.json');
await rm(statePath, { force: true });
await mkdir(statePath, { recursive: true });

await engine.sendUserMessage(chatId, 'Ship the hotfix', [], 'session-write').catch(() => {});
await until(() => idle(engine));
await new Promise((resolve) => setTimeout(resolve, 50));

// The Host fails the whole Mini App process on an unhandled rejection, so this one has to be caught.
assert.deepEqual(rejected.map((error) => error?.code ?? 'unknown'), []);
assert.ok(logged.includes('minimax_bot.session_save_failed'), `logged: ${logged.join(',')}`);
engine.dispose();
await store.writeChain.catch(() => {});
});

test('a failed save in the schedule tick is reported, not thrown as an unhandled rejection', async (t) => {
const { dir, store, memory } = await fixture(t);
const bot = store.state.bots[0];
const rejected = [];
const onRejection = (error) => rejected.push(error);
process.on('unhandledRejection', onRejection);
t.after(() => process.removeListener('unhandledRejection', onRejection));

// A schedule that is already due, so one tick touches it.
store.state.schedules.push({
id: 'sch_due', createdAt: Date.now(), name: 'Due', botId: bot.id, prompt: 'Ping',
kind: 'interval', time: '09:00', everyMinutes: 60, enabled: true, nextRunAt: Date.now() - 1000,
});
await store.save();

const logged = [];
const engine = new Engine({ store, memory, logger: { warn: (key) => logged.push(key) }, broadcast() {}, retryDelaysMs: [], agent: {
async run() { return { sessionId: 's', turnId: 'turn-2', status: 'finished', text: 'ok' }; },
} });
const statePath = join(dir, 'state.json');
await rm(statePath, { force: true });
await mkdir(statePath, { recursive: true });

// The scheduler fires the tick without awaiting it, so a rejection would surface as an unhandled
// rejection unless the engine catches it.
engine.startScheduler();
await new Promise((resolve) => setTimeout(resolve, 80));

assert.deepEqual(rejected.map((error) => error?.code ?? 'unknown'), []);
assert.ok(logged.includes('minimax_bot.schedule_tick_failed'), `logged: ${logged.join(',')}`);
engine.dispose();
await store.writeChain.catch(() => {});
});