Skip to content

feat(minimax): add MiniMax M3 models (512K / 1M context) and fix double-think on Anthropic endpoint#765

Open
hameedirfan wants to merge 4 commits into
Zoo-Code-Org:mainfrom
hameedirfan:feat/minimax-m3-512k-1m
Open

feat(minimax): add MiniMax M3 models (512K / 1M context) and fix double-think on Anthropic endpoint#765
hameedirfan wants to merge 4 commits into
Zoo-Code-Org:mainfrom
hameedirfan:feat/minimax-m3-512k-1m

Conversation

@hameedirfan

@hameedirfan hameedirfan commented Jun 29, 2026

Copy link
Copy Markdown

Summary

This PR adds the MiniMax M3 model family to the MiniMax provider and ports
a small but important fix from the kilo-code opencode engine to keep M-series
models from hanging/double-thinking on the Anthropic Messages endpoint.

What's new

  • *\MiniMax-M3-512k* — 65,536 max output, 524,288-token context, multimodal input, prompt caching, M-series tool preferences (search_and_replace preferred, apply_diff excluded), reasoning preserved across turns.
  • *\MiniMax-M3-1M* — 131,072 max output, 1,048,576-token context (1M tokens), same multimodal/cache/tool config as the 512K variant.
  • New default model: \minimaxDefaultModelId\ is now \MiniMax-M3-1M. Existing \MiniMax-M2.7\ and other M2.x IDs are still resolvable for back-compat.
  • Pricing matches the M2 flat tier: .30/M input, .20/M output, .06/M cache read, .375/M cache write. \longContextPricing\ is intentionally not set — see regression guard below.

Bug fix (ported from kilo-code opencode \provider/transform.ts)

When routing M-series models through the Anthropic Messages endpoint
(\�pi.minimax.io/anthropic), MiniMax defaults \ hinking\ to off. The model
would emit a cheap non-thinking response on the first turn, then re-decide to
think from scratch on the next turn, producing the double-think / hang
symptom on multi-turn agentic runs.

The fix mirrors kilo-code's opencode provider (lines 488–524, 661–669, 907–914,
1208–1211) and is implemented in \src/api/providers/minimax.ts:

  • For \MiniMax-M3-*\ models: inject \ hinking: { type: adaptive }\ and pass
    \ emperature: 1.0, \ op_p: 0.95. Never set \�udget_tokens\ — M-series
    is a binary on/off toggle (matching kilo's \instant: { thinking: { type: disabled } }, thinking: { thinking: { type: adaptive }\ mapping).
  • For \MiniMax-M2.x\ models: pass \ emperature: 1.0, \ op_p: 0.95, \ op_k: 40
    (matches kilo's \minimax-m2\ defaults at lines 488–524). No \ hinking\ field —
    M2.x does not accept it.
  • Inline comments in the provider cite the kilo-code line ranges so future
    maintainers can re-sync if kilo's logic changes.

Files changed

File Change
\packages/types/src/providers/minimax.ts\ +40 lines — add M3-512k and M3-1M model entries; switch default to M3-1M.
\packages/types/src/tests/provider-settings.test.ts\ +12 lines — new \MiniMax provider\ describe block asserting M3 and M2.x all route to \�nthropic\ protocol.
\src/api/providers/minimax.ts\ +19 lines — adaptive-thinking + sampling params per the kilo port (replace existing 1-line temperature set).
\src/api/providers/tests/minimax.spec.ts\ +199 lines — 4 new tests: M3 enables adaptive thinking, M2.x does not, M2 sampling params (\ op_p=0.95, \ op_k=40), M3 sampling params (\ op_p=0.95, no \ op_k); plus existing tests updated.
\webview-ui/src/components/ui/hooks/tests/useSelectedModel.spec.ts\ +34 lines — two new tests verifying M3-512k and M3-1M resolve with correct contextWindow / maxTokens / supportsImages.

Tests

\
packages/types → provider-settings.test.ts → 17/17 passed
src → minimax.spec.ts → 42/42 passed (38 prior + 4 new)
webview-ui → useSelectedModel.spec.ts → 27/27 passed
Total 86/86 passed
\\

Regression guards

  • \expect(JSON.stringify(minimaxModels[MiniMax-M3-512k])).not.toContain(longContextPricing)\ — protects the intentional flat-tier pricing decision.
  • \expect(lastCall.thinking).not.toHaveProperty(budget_tokens)\ — prevents future regressions to Anthropic-style effort-level knobs that don't apply to M-series.
  • \expect(lastCall.thinking).toBeUndefined()\ for M2.x — protects against accidentally enabling thinking on a model family that doesn't accept it.

Why no changesets?

Per \AGENTS.md\ in this repo:

Changesets: Do NOT create .changeset\ files for each commit or code change. Changesets are managed separately by maintainers and should not be generated by agents during normal development.

Why this PR is targeted at \Zoo-Code-Org/Zoo-Code, not a fork

This contribution is intended for the upstream project. Please review and let
me know if you'd like any of the optional follow-ups below; happy to address
in follow-up PRs.

Optional follow-ups (NOT in this PR)

  • Per-tenant pricing table support for MiniMax TokenPlan variants (highspeed / pricing-by-request).
  • A webview settings UI hint that surfaces the new 1M-context model explicitly (currently it's just the default and one of the entries in the model dropdown).
  • A CHANGELOG entry, added separately by maintainers per the changeset policy.

Verification steps for reviewers

  1. \pnpm install && pnpm vsix\ to build a fresh VSIX.
  2. Install the vsix and add the MiniMax provider with an API key.
  3. Set the default model — the picker should show \MiniMax-M3-1M\ (1M tokens).
  4. Run an agentic task that requires at least one tool call. Confirm:
    • The reasoning block appears on turn 1 (thinking is on).
    • Subsequent turns continue reasoning without re-thinking the world from scratch (no double-think).
    • Long prompts do not produce over-long sampling cycles (no hang).
  5. Run \pnpm test\ from the workspace root to confirm 86/86 tests pass.

Summary by CodeRabbit

  • New Features

    • Added two new MiniMax model options: MiniMax-M3-512k and MiniMax-M3-1M, with updated context limits, image + prompt cache support, and revised pricing details.
    • Updated the MiniMax default model to MiniMax-M3-1M.
  • Bug Fixes

    • Improved Anthropic-compatible MiniMax requests for M3 models, including adaptive thinking, consistent sampling behavior, omission of budget tokens, and correct model-specific max-token limits (with preserved MiniMax-M2.7 back-compat).
  • Tests

    • Expanded handler, provider-resolution, API request regression, and UI selection coverage for the new M3 variants.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3df1bb12-5fee-4e92-acee-937729f6b3d5

📥 Commits

Reviewing files that changed from the base of the PR and between 6264171 and b770d61.

📒 Files selected for processing (1)
  • src/api/providers/minimax.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/api/providers/minimax.ts

📝 Walkthrough

Walkthrough

Adds MiniMax-M3-512k and MiniMax-M3-1M to the MiniMax registry, updates the default model, changes MiniMax Anthropic request parameter mapping for M-series models, and extends protocol, handler, and UI tests.

Changes

MiniMax M3 Model Support

Layer / File(s) Summary
M3 model registry and default update
packages/types/src/providers/minimax.ts
Adds MiniMax-M3-512k and MiniMax-M3-1M entries with capacity, feature flags, pricing, and descriptions, and updates minimaxDefaultModelId to MiniMax-M3-1M.
Protocol and registry tests
packages/types/src/__tests__/provider-settings.test.ts, src/api/providers/__tests__/minimax.spec.ts
Adds getApiProtocol coverage for minimax across MiniMax model IDs and default behavior, plus registry assertions for the new M3 model configurations and existing M2.7 explicit resolution.
M-series request parameter mapping
src/api/providers/minimax.ts, src/api/providers/__tests__/minimax.spec.ts
Drops per-model temperature usage, adds shared M-series request params, and applies them to createMessage and completePrompt with M3 adaptive thinking, M2 sampling defaults, and related request-shape tests.
UI model resolution and config guards
webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts, src/api/providers/__tests__/minimax.spec.ts
Adds UI resolution coverage for the new M3 models and extends config assertions for prompt cache, pricing, and longContextPricing absence.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

awaiting-review

Suggested reviewers

  • taltas
  • hannesrudolph
  • navedmerchant
  • JamesRobert20

Poem

🐰 Two MiniMax stars hop into view,
M3-512k and M3-1M too.
Adaptive thinking, neat and bright,
The rabbit nods at model night. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it omits the required linked issue section and several template sections from the repo format. Add a Related GitHub Issue link (Closes: #...), and include the missing template sections or clearly mark them as intentionally omitted.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding MiniMax M3 models and fixing Anthropic double-think behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/api/providers/__tests__/minimax.spec.ts`:
- Around line 669-677: The MiniMax-M3 pricing regression tests in minimax.spec
should verify that longContextPricing is truly unset on the model objects, not
just absent from JSON output. Update the two assertions that inspect
minimaxModels["MiniMax-M3-512k"] and minimaxModels["MiniMax-M3-1M"] to check the
property directly on the object so the tests fail if longContextPricing is added
as undefined.

In `@src/api/providers/minimax.ts`:
- Around line 111-130: The M3 request-shape fix is only applied in
createMessage, but completePrompt still builds M-series requests without the
same adaptive-thinking and top_p settings. Extract the shared M-series
request-parameter construction in Minimaxi provider code (for example around
createMessage/completePrompt request assembly) and reuse it in both paths so the
default M3 model gets identical request params everywhere.
- Around line 112-114: The Minimax sampling defaults still allow user-provided
temperature to override the regression-guarded M-series setting; update the
`samplingParams` construction in `minimax.ts` so `isM3` (and the M2/M3 path it
represents) always uses a fixed `temperature: 1.0` instead of `temperature ??
1.0`. Keep the existing `top_p`/`top_k` behavior unchanged, and add provider
test coverage around the relevant Minimax provider methods to verify custom
temperature input is ignored for the M-series default path while still behaving
as expected elsewhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6eb19bc3-6440-4a8f-8c2a-0a0f4178ab66

📥 Commits

Reviewing files that changed from the base of the PR and between 515437b and 36ccbcf.

📒 Files selected for processing (5)
  • packages/types/src/__tests__/provider-settings.test.ts
  • packages/types/src/providers/minimax.ts
  • src/api/providers/__tests__/minimax.spec.ts
  • src/api/providers/minimax.ts
  • webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts

Comment thread src/api/providers/__tests__/minimax.spec.ts Outdated
Comment thread src/api/providers/minimax.ts Outdated
Comment thread src/api/providers/minimax.ts Outdated
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/providers/minimax.ts 66.66% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/api/providers/minimax.ts`:
- Around line 318-326: The completePrompt() flow is still hard-coding the old M2
max token limit even though it now uses M3 request params and the selected
model’s registry settings. Update the MiniMaxProvider.completePrompt method to
use the selected model’s maxTokens (as createMessage() already does) instead of
the fixed 16_384 value, and keep the model lookup via getModel() /
getMSeriesRequestParams(model) consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e6afa1d6-1025-42bf-b57c-5a7d6ebe3a3f

📥 Commits

Reviewing files that changed from the base of the PR and between 36ccbcf and 47738e7.

📒 Files selected for processing (2)
  • src/api/providers/__tests__/minimax.spec.ts
  • src/api/providers/minimax.ts

Comment thread src/api/providers/minimax.ts
…max_tokens fallback

The literal 16_384 fallback in both createMessage and completePrompt is
the same value exported from @roo-code/types as MINIMAX_DEFAULT_MAX_TOKENS
(the registry's own default). Using the constant:

- Removes a duplicated magic number.
- Self-documents the call site - readers no longer have to guess what
  16_384 means in the context of MiniMax.
- Matches the pattern used elsewhere in the file (e.g. defaultTemperature:
  1.0 in getModel).
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant