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
39 changes: 22 additions & 17 deletions src/agent/configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function minimaxModel(modelId: MiniMaxModelId) {
}

function claudeModelId(modelId: MiniMaxModelId): string {
return modelId === 'MiniMax-M3.1-Flash' || modelId === 'MiniMax-M3'
return modelId === 'MiniMax-M4' || modelId === 'MiniMax-M3.1-Flash' || modelId === 'MiniMax-M3'
? `${modelId}[1m]`
: modelId;
}
Expand Down Expand Up @@ -781,7 +781,7 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen
`OpenCode model definition for ${model.id} modalities must be an object.`,
);
}
if (model.id === 'MiniMax-M3.1-Flash') {
if (model.id !== 'MiniMax-M3') {
const variants = (configuredModel as Record<string, unknown> | undefined)?.variants;
if (variants !== undefined) {
assertObject(variants, `OpenCode model definition for ${model.id} variants must be an object.`);
Expand Down Expand Up @@ -818,17 +818,19 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen
},
];
});
const m31Path = ['provider', 'minimax', 'models', 'MiniMax-M3.1-Flash'];
const m31Updates = [
{ path: [...m31Path, 'interleaved'], value: { field: 'reasoning_content' } },
{ path: [...m31Path, 'variants', 'none', 'disabled'], value: true },
{ path: [...m31Path, 'variants', 'thinking', 'disabled'], value: true },
{ path: [...m31Path, 'variants', 'default', 'reasoningEffort'], value: 'max' },
...(['low', 'medium', 'high', 'xhigh', 'max'] as const).map(effort => ({
path: [...m31Path, 'variants', effort, 'reasoningEffort'],
value: effort,
})),
];
const alwaysThinkingUpdates = (['MiniMax-M4', 'MiniMax-M3.1-Flash'] as const).flatMap((id) => {
const modelPath = ['provider', 'minimax', 'models', id];
return [
{ path: [...modelPath, 'interleaved'], value: { field: 'reasoning_content' } },
{ path: [...modelPath, 'variants', 'none', 'disabled'], value: true },
{ path: [...modelPath, 'variants', 'thinking', 'disabled'], value: true },
{ path: [...modelPath, 'variants', 'default', 'reasoningEffort'], value: 'max' },
...(['low', 'medium', 'high', 'xhigh', 'max'] as const).map(effort => ({
path: [...modelPath, 'variants', effort, 'reasoningEffort'],
value: effort,
})),
];
});
return [{
agent: 'opencode',
path,
Expand All @@ -840,7 +842,7 @@ function prepareOpenCode(options: AgentSetupOptions, path: string): PreparedAgen
{ path: ['provider', 'minimax', 'options', 'apiKey'], value: options.apiKey },
{ path: ['provider', 'minimax', 'options', 'setCacheKey'], value: undefined },
...modelUpdates,
...m31Updates,
...alwaysThinkingUpdates,
{ path: ['model'], value: `minimax/${options.model}` },
]),
}];
Expand Down Expand Up @@ -982,6 +984,9 @@ function preparePi(options: AgentSetupOptions, paths: string[]): PreparedAgentFi
after: updateJsonc(settings.before, 'Pi settings.json', [
{ path: ['defaultProvider'], value: providerId },
{ path: ['defaultModel'], value: options.model },
...(options.model === 'MiniMax-M4'
? [{ path: ['defaultThinkingLevel'], value: 'max' }]
: []),
]),
},
];
Expand Down Expand Up @@ -1028,7 +1033,7 @@ function prepareOhMyPi(options: AgentSetupOptions, paths: string[]): PreparedAge
input: [...model.input],
contextWindow: model.contextWindow,
maxTokens: model.maxTokens,
...(model.id === 'MiniMax-M3.1-Flash' ? {
...(model.id !== 'MiniMax-M3' ? {
thinking: {
mode: 'anthropic-adaptive',
efforts: ['low', 'medium', 'high', 'xhigh', 'max'],
Expand All @@ -1048,7 +1053,7 @@ function prepareOhMyPi(options: AgentSetupOptions, paths: string[]): PreparedAge
}
} else {
if (root.modelRoles !== undefined) assertObject(root.modelRoles, `${label} modelRoles must be an object.`);
const effort = options.model === 'MiniMax-M3.1-Flash' ? ':max' : '';
const effort = options.model !== 'MiniMax-M3' ? ':max' : '';
document.setIn(['modelRoles', 'default'], `${providerId}/${options.model}${effort}`);
}
return { agent: 'oh-my-pi', path, ...existing, after: document.toString() };
Expand Down Expand Up @@ -1087,7 +1092,7 @@ function prepareZed(options: AgentSetupOptions, path: string): PreparedAgentFile
}

// Thinking is always on for MiniMax models; Zed treats "none" as thinking disabled.
const effortFor = (modelId: MiniMaxModelId) => modelId === 'MiniMax-M3.1-Flash' ? 'max' : 'high';
const effortFor = (modelId: MiniMaxModelId) => modelId !== 'MiniMax-M3' ? 'max' : 'high';
const prefix = ['language_models', 'openai_compatible', 'minimax'];
const definitions = MINIMAX_MODELS.map(model => ({
name: model.id,
Expand Down
16 changes: 16 additions & 0 deletions src/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ export const MINIMAX_MODELS = [
],
},
},
{
id: 'MiniMax-M4',
contextWindow: 1_000_000,
maxTokens: 131072,
input: ['text', 'image'],
codex: {
defaultReasoningLevel: 'max',
supportedReasoningLevels: [
{ effort: 'low', description: 'Low' },
{ effort: 'medium', description: 'Medium' },
{ effort: 'high', description: 'High' },
{ effort: 'xhigh', description: 'Extra high' },
{ effort: 'max', description: 'Maximum' },
],
},
},
{
id: 'MiniMax-M3',
contextWindow: 1_000_000,
Expand Down
28 changes: 23 additions & 5 deletions test/agent/configurator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('agent configurator', () => {
label: 'MiniMax-M3.1-Flash',
description: '1M supported',
},
{ model: 'MiniMax-M4[1m]', label: 'MiniMax-M4', description: '1M supported' },
{ model: 'MiniMax-M3[1m]', label: 'MiniMax-M3', description: '1M supported · 1M compact' },
],
replaceBuiltInOptions: false,
Expand All @@ -182,7 +183,7 @@ describe('agent configurator', () => {
readFileSync(join(home, '.codex', 'mmx-model-catalog.json'), 'utf8'),
);
expect(codexCatalog._managed_by).toBe('mmx agent setup');
expect(codexCatalog.models).toHaveLength(2);
expect(codexCatalog.models).toHaveLength(3);
expect(codexCatalog.models[0]).toMatchObject({
slug: 'MiniMax-M3.1-Flash',
description: 'MiniMax M3.1 Flash',
Expand Down Expand Up @@ -212,9 +213,16 @@ describe('agent configurator', () => {
input_modalities: ['text', 'image'],
});
expect(codexCatalog.models[1]).toMatchObject({
slug: 'MiniMax-M3',
slug: 'MiniMax-M4',
description: 'MiniMax',
priority: 1,
default_reasoning_level: 'max',
context_window: 1_000_000,
});
expect(codexCatalog.models[2]).toMatchObject({
slug: 'MiniMax-M3',
description: 'MiniMax',
priority: 2,
base_instructions: 'You are Codex, a coding agent based on MiniMax-M3. '
+ "You and the user share the same workspace and collaborate to achieve the user's goals.",
shell_type: 'shell_command',
Expand All @@ -228,8 +236,8 @@ describe('agent configurator', () => {
{ effort: 'high', description: 'Deep' },
],
});
expect(codexCatalog.models).toHaveLength(2);
expect(codexCatalog.models[1].apply_patch_tool_type).toBe('freeform');
expect(codexCatalog.models).toHaveLength(3);
expect(codexCatalog.models[2].apply_patch_tool_type).toBe('freeform');

const m31Home = join(tmpdir(), `mmx-agent-config-m31-${process.pid}-${Date.now()}`);
mkdirSync(join(m31Home, '.codex'), { recursive: true });
Expand Down Expand Up @@ -275,8 +283,11 @@ describe('agent configurator', () => {
for (const effort of ['low', 'medium', 'high', 'xhigh', 'max']) {
expect(m31OpenCode.variants[effort].reasoningEffort).toBe(effort);
}
expect(openCode.provider.minimax.models['MiniMax-M4'].variants)
.toEqual({ ...m31OpenCode.variants, default: { reasoningEffort: 'max' } });
expect(openCode.provider.minimax.models['MiniMax-M4'].limit).toEqual({ context: 1_000_000, output: 131072 });
expect(Object.keys(openCode.provider.minimax.models).sort())
.toEqual(['MiniMax-M3', 'MiniMax-M3.1-Flash', 'keep-model']);
.toEqual(['MiniMax-M3', 'MiniMax-M3.1-Flash', 'MiniMax-M4', 'keep-model']);

const hermes = parseYaml(readFileSync(join(home, '.hermes', 'config.yaml'), 'utf8'));
expect(hermes.model.provider).toBe('minimax-cn');
Expand All @@ -286,6 +297,7 @@ describe('agent configurator', () => {
expect(Object.keys(hermes.model_overrides['minimax-cn']))
.toEqual([
'MiniMax-M3.1-Flash',
'MiniMax-M4',
'MiniMax-M3',
]);
expect(hermes.model_overrides['minimax-cn']['MiniMax-M3'].context_window)
Expand Down Expand Up @@ -323,8 +335,13 @@ describe('agent configurator', () => {
'keep-model',
'MiniMax-M3',
'MiniMax-M3.1-Flash',
'MiniMax-M4',
]);
expect(piSettings).toMatchObject({ defaultProvider: 'minimax-cn', defaultModel: 'MiniMax-M3' });
const m4Home = join(tmpdir(), `mmx-agent-config-m4-pi-${process.pid}-${Date.now()}`);
applyAgentConfigurations(prepareAgentConfigurations(setupOptions(['pi'], { homeDir: m4Home, model: 'MiniMax-M4' })));
expect(JSON.parse(readFileSync(join(m4Home, '.pi', 'agent', 'settings.json'), 'utf8')).defaultThinkingLevel).toBe('max');
rmSync(m4Home, { recursive: true, force: true });

for (const file of result) {
expect(statSync(file.path).mode & 0o777).toBe(0o600);
Expand Down Expand Up @@ -512,6 +529,7 @@ describe('agent configurator', () => {
expect(configured.providers.minimax.models.map((model: { id: string }) => model.id))
.toEqual([
'MiniMax-M3.1-Flash',
'MiniMax-M4',
'MiniMax-M3',
]);
expect(configured.providers.minimax.models[0]).toMatchObject({
Expand Down
4 changes: 2 additions & 2 deletions test/agent/zed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Zed configuration', () => {
expect(JSON.stringify(settings)).not.toContain(options.apiKey);
const models = provider.available_models;
expect(models.map((model: { name: string }) => model.name))
.toEqual(['keep-model', 'MiniMax-M3', 'MiniMax-M3.1-Flash']);
.toEqual(['keep-model', 'MiniMax-M3', 'MiniMax-M3.1-Flash', 'MiniMax-M4']);
expect(models[2]).toMatchObject({
max_tokens: 524288, max_output_tokens: 128000, reasoning_effort: 'max',
capabilities: { tools: true, images: true, interleaved_reasoning: true, chat_completions: true },
Expand All @@ -68,7 +68,7 @@ describe('Zed configuration', () => {
expect(file?.path).toBe(join(xdg, 'zed', 'settings.json'));
const settings = parse(file!.after);
expect(settings.agent.default_model).toMatchObject({ model: 'MiniMax-M3', effort: 'high' });
expect(settings.language_models.openai_compatible.minimax.available_models).toHaveLength(2);
expect(settings.language_models.openai_compatible.minimax.available_models).toHaveLength(3);
});

it('uses the 1M Flash window when selected', () => {
Expand Down
Loading