Skip to content
Open
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.41",
"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",
Expand Down
8 changes: 8 additions & 0 deletions plugins/minimax-ai/minimax-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ The hand-over between two Bots of a group carried the tail of the previous reply
- 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.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.
- Restart recovery now reads the reply's own status, and it decides the same way the live path does. A reply that finished — or that only passed, which is a finished turn with nothing to add — means the request was delivered. A reply that failed after the Host had taken the turn means nobody can say whether it was answered, so it stays uncertain and the later requests wait. A reply that failed before the Host took the turn at all carries the words to send again, so the request stays the user's to send, and no reply still means it never reached the Host.
- A failure the Host vouches for is the exception: the turn certainly did not happen. Those are the codes the live path lets the chat continue after, and the recovery reads the same list. A timeout is not one of them — the turn may have run anyway — so a timed-out reply leaves the request uncertain even when it carries the words to send again.
- When one request has several replies, a reply nobody can vouch for decides: the request may not be called delivered while a turn of it is unaccounted for.
- The rules live in exported predicates, so the retry path and restart recovery cannot drift apart again.

## 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
115 changes: 115 additions & 0 deletions plugins/minimax-ai/minimax-bot/miniapp/node/delivery.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// @ts-check

/**
* The failure codes the Host vouches for: the turn certainly did not happen, so the chat may go
* on and the request stays the user's to send again.
*
* The live path and the restart recovery read the same list, so a failure one of them calls
* clean is clean for the other as well.
*/
export const CLEAN_FAILURE_CODES = new Set([
'BUSY', 'NOT_PERMITTED', 'INVALID_ARGUMENTS', 'AGENT_UNAVAILABLE', 'SESSION_NOT_FOUND',
]);

/**
* A reply nobody can vouch for.
*
* The Host may have taken the turn before it failed, so nobody can say whether the request was
* answered. A reply that never finished is such a reply, and so is a failure the Host does not
* vouch for: a timeout says the turn may have run, while the codes in `CLEAN_FAILURE_CODES` say
* it did not.
*
* @param {any} reply
* @returns {boolean}
*/
export function replyOutcomeUnknown(reply) {
return replyDeliveryState(reply) === 'uncertain';
}

/**
* A reply that answers the request: the turn finished and it produced an answer.
*
* A reply that failed is not one — the Host may have taken the turn before the failure, so the
* outcome is unknown and the request must not be declared delivered. A pass is one: the Bot
* finished the turn and had nothing to add, which is what the live path records as delivered.
*
* @param {any} reply
* @returns {boolean}
*/
export function replyDelivered(reply) {
return reply?.status === 'done' || reply?.status === 'pass';
}

/**
* A reply that failed before the Host ever took the turn: the work was never done, so the
* request is still the user's to send again.
*
* The reply carries the words to resend only when the Host never took the turn, so its presence
* is the proof. A reply that never reached a session says the same thing: a thrown failure has
* no session unless the Host had already started the turn.
*
* @param {any} reply
* @returns {boolean}
*/
export function replyNeverReachedHost(reply) {
if (reply?.status !== 'error') return false;
if (!CLEAN_FAILURE_CODES.has(reply?.errorCode)) return false;
if (typeof reply?.retryInput === 'string' && reply.retryInput.length > 0) return true;
return !reply?.sessionId;
}

/**
* The state a user's line carries after a turn.
*
* The live path writes this onto the line; the restart recovery arrives at the same state by
* reading the replies of that turn.
*
* @param {{errorCode?: string, safeToContinue?: boolean, pendingQuestion?: boolean, skipped?: boolean, accepted?: boolean} | undefined} result
* @returns {'uncertain' | 'cancelled' | 'delivered' | 'failed'}
*/
export function deliveryState(result) {
if (result?.errorCode === 'AGENT_OUTCOME_UNKNOWN' || (result?.safeToContinue === false && !result?.pendingQuestion)) {
return 'uncertain';
}
if (result?.skipped) return 'cancelled';
if (result?.accepted) return 'delivered';
return 'failed';
}

/**
* What one reply says about the request it answers.
*
* The live path writes the same states onto the user's line when the turn ends; the restart
* recovery reads them off the reply, because the reply is written before that verdict lands and
* a process that stops in between leaves the request in flight.
*
* @param {any} reply
* @returns {'delivered' | 'uncertain' | 'failed' | 'cancelled'}
*/
export function replyDeliveryState(reply) {
// The Host answered with an error of its own: the turn happened and the answer was a failure.
// The request was delivered, which is what the live path records for it.
if (reply?.status === 'error' && reply?.errorReason !== undefined) return 'delivered';
if (replyDelivered(reply)) return 'delivered';
// The turn was dropped before it reached the Agent: nobody was asked anything.
if (reply?.status === 'aborted') return 'cancelled';
if (replyNeverReachedHost(reply)) return 'failed';
return 'uncertain';
}

/**
* What several replies say about one request.
*
* An unknown outcome outranks the rest: one reply nobody can vouch for is enough to hold the
* request back, even when another reply says the turn finished.
*
* @param {Array<'delivered' | 'uncertain' | 'failed' | 'cancelled'>} states
* @returns {'delivered' | 'uncertain' | 'failed' | 'cancelled' | 'pending'}
*/
export function mergeDeliveryStates(states) {
if (states.includes('uncertain')) return 'uncertain';
if (states.includes('delivered')) return 'delivered';
if (states.includes('failed')) return 'failed';
if (states.includes('cancelled')) return 'cancelled';
return 'pending';
}
8 changes: 3 additions & 5 deletions plugins/minimax-ai/minimax-bot/miniapp/node/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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 { CLEAN_FAILURE_CODES, replyOutcomeUnknown } from './delivery.mjs';
import { modelKey, newId, 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';
Expand Down Expand Up @@ -928,9 +929,7 @@ export class Engine {
toolCount: tools,
accepted: reachedHost || Boolean(result && !result.skipped),
// A returned terminal result is known; exceptions after admission may have lost observation.
safeToContinue: Boolean(result && !result.pendingQuestion) || (!reachedHost && (!invoked || [
'BUSY', 'NOT_PERMITTED', 'INVALID_ARGUMENTS', 'AGENT_UNAVAILABLE', 'SESSION_NOT_FOUND',
].includes(failureCode))),
safeToContinue: Boolean(result && !result.pendingQuestion) || (!reachedHost && (!invoked || CLEAN_FAILURE_CODES.has(failureCode))),
skipped: Boolean(result?.skipped),
// The turn ended waiting for the user: its text is not the Bot's final answer.
pendingQuestion: Boolean(result?.pendingQuestion),
Expand Down Expand Up @@ -1187,8 +1186,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'));
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.41' },
serverInfo: { name: 'minimax-bot', version: '0.7.46' },
instructions: t('mcp.instructions'),
};
break;
Expand Down
10 changes: 9 additions & 1 deletion plugins/minimax-ai/minimax-bot/miniapp/node/store.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { appendFile, copyFile, mkdir, open, readFile, rename, rm } from 'node:fs
import { basename, dirname, join } from 'node:path';
import { userReaction } from '../client/emoji-data.js';

import { mergeDeliveryStates, replyDeliveryState } from './delivery.mjs';
import { resolveLocale, setLocale, t } from './i18n.mjs';
import { ReactionError, validateReaction } from './reactions.mjs';

export const DEFAULT_MESSAGE_PAGE_SIZE = 100;
export const MAX_MESSAGE_PAGE_SIZE = 500;

/** 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',
Expand Down Expand Up @@ -511,8 +513,14 @@ 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));
// The reply is written before the inbox writes the verdict onto the user's line, so a
// process that stops in between leaves the request in flight. The replies say what the
// turn was: one that finished proves the request was delivered, one nobody can vouch for
// leaves it undecided, and one that failed before the Host took the turn means the work
// was never done, so the request is still the user's to send again.
message.dispatchState = message.dispatchState === 'adjusting' ? 'held'
: list.some((reply) => reply.sourceMessageId === message.id || reply.sourceMessageIds?.includes(message.id)) ? 'uncertain' : 'pending';
: mergeDeliveryStates(replies.map(replyDeliveryState));
message.dispatchRevision = (message.dispatchRevision ?? 0) + 1;
dirty = true;
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/minimax-ai/minimax-bot/miniapp/node/user-inbox.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
import { deliveryState } from './delivery.mjs';
import { t } from './i18n.mjs';

const MAX_BATCH_CHARS = 60000;
Expand Down Expand Up @@ -75,8 +76,7 @@ export class UserInbox {
return { safeToContinue: true, accepted: false };
}
const result = await this.engine.runUserBatch(batch);
await this.setDeliveryState(batch, result?.errorCode === 'AGENT_OUTCOME_UNKNOWN' || (result?.safeToContinue === false && !result?.pendingQuestion)
? 'uncertain' : result?.skipped ? 'cancelled' : result?.accepted ? 'delivered' : 'failed');
await this.setDeliveryState(batch, deliveryState(result));
if (result?.safeToContinue === false || result?.pendingQuestion) {
// Pending supplements must not silently bypass an unresolved turn or questionnaire.
for (const next of this.batches) if (next.chatId === chatId && !next.started) await this.setDeliveryState(next, 'held');
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.41",
"version": "0.7.46",
"private": true,
"type": "module",
"mcode": {
Expand Down
Loading