fix(minimax): recognize Anthropic-compatible /anthropic endpoint in M3 reasoning controls - #74205
Conversation
There was a problem hiding this comment.
Pull request overview
Extends the MiniMax provider plugin’s M3 reasoning controls to also recognize MiniMax’s Anthropic-compatible global /anthropic base URL, so the OpenAI-shaped extra_body can enable/disable M3 “thinking” correctly on both /v1 and /anthropic routes.
Changes:
- Add
_is_minimax_global_anthropic_base_url()to detecthttps://api.minimax.io/anthropic. - Update
MiniMaxProfile.build_api_kwargs_extras()to applythinkingon/v1and/anthropic, while only emittingreasoning_split=Truefor/v1. - Clarify provider-profile docstrings to reflect dual-route behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| is_m3 = _is_minimax_m3(model) | ||
| is_oai = _is_minimax_global_openai_base_url(base_url) | ||
| is_ant = _is_minimax_global_anthropic_base_url(base_url) | ||
|
|
||
| if not is_m3 or (not is_oai and not is_ant): |
…3 reasoning controls Extends the `MiniMaxProfile.build_api_kwargs_extras` provider plugin to recognize MiniMax's Anthropic-compatible `/anthropic` endpoint at `api.minimax.io/anthropic`, in addition to the existing `api.minimax.io/v1` OpenAI-compatible route. ## Why this is separate from NousResearch#66694 NousResearch#66694 (`fix(minimax): preserve M3 adaptive thinking on Anthropic routes`) covers the Anthropic adapter layer — the request kwargs that go out as Anthropic `thinking: {"type": "adaptive"}` on the `auxiliary_client` adapter path. That's correct and stays open. This PR covers the provider plugin layer — the `extra_body` that goes out on the OpenAI-compatible request shape that MiniMax's `/anthropic` endpoint also accepts. Different code path, different kwargs structure. ## The bug On the `/anthropic` endpoint, omitting `thinking` causes MiniMax-M3 to default to OFF (per MiniMax docs). Previously, the provider plugin only matched `/v1`, so requests to `/anthropic` got an empty extra_body and M3 returned thinking as disabled. ## The fix Add `_is_minimax_global_anthropic_base_url()` helper that matches `api.minimax.io/anthropic`. Update `build_api_kwargs_extras` to: - Accept both `/v1` and `/anthropic` (the existing `/v1` condition becomes an OR with the new `/anthropic` condition). - Send `reasoning_split=True` only on `/v1` (the `/anthropic` endpoint already returns thinking as native content blocks, no split flag needed). - Send `thinking: {type: adaptive}` (or `disabled` if reasoning is explicitly disabled) on both routes. ## Out of scope The `/anthropic` route also requires stateful replay preservation across multi-turn tool calls, which is the focus of the Anthropic adapter work in NousResearch#66694. The provider plugin here only handles the request-shape kwargs.
cb3375f to
913217a
Compare
|
Rebased onto current As noted in the PR description, this PR complements #66694 (Anthropic adapter layer) — together they cover both sides of the M3 Anthropic-route contract: #66694 keeps |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the /v1 versus /anthropic distinction.
Problems
- The added profile branch cannot alter the normal
/anthropicrequest path. Current URL routing selectsanthropic_messagesfor that suffix (hermes_cli/runtime_provider.py:135), and that transport callsbuild_anthropic_kwargs()directly (agent/transports/anthropic.py:63-78) rather thanMiniMaxProfile.build_api_kwargs_extras(). The current M3 behavior to change is the manual-thinking branch atagent/anthropic_adapter.py:2866-2887. - This diff contains no tests: the PR file API lists only
plugins/model-providers/minimax/__init__.py. Current profile tests instead assert/anthropicemits no OpenAI-route controls (tests/plugins/model_providers/test_minimax_profile.py:141-163).
Suggested changes
- Consolidate this with the Anthropic adapter-layer work in #66694, where the endpoint/model gate can affect the actual Messages request.
- Add enabled, disabled, unset, and endpoint/model-negative regression coverage through
build_anthropic_kwargs()orAnthropicTransport.
Automated hermes-sweeper review.
| if not _is_minimax_global_openai_base_url(base_url) or not _is_minimax_m3(model): | ||
| is_m3 = _is_minimax_m3(model) | ||
| is_oai = _is_minimax_global_openai_base_url(base_url) | ||
| is_ant = _is_minimax_global_anthropic_base_url(base_url) |
There was a problem hiding this comment.
/anthropic resolves to the anthropic_messages transport (hermes_cli/runtime_provider.py:135), which calls build_anthropic_kwargs() directly (agent/transports/anthropic.py:63-78) and does not consume this profile hook. Please place this endpoint/model-specific behavior in the Anthropic adapter (or consolidate it with #66694), where it changes the actual wire request.
|
@teknium1 is right, and I verified it independently rather than taking the review at face value. Three findings, the first two decisive: 1. This is a no-op on the route it targets. A 2. It breaks an existing test. Ran it on this branch: 1 failed, 16 passed. The PR ships no test changes, so this would land red. 3. The matcher misses the CN endpoint. #66694 already does this correctly. Its There's also a real hazard in landing both: Closing in favor of #66694. Correcting the record on my own earlier comment too: it claimed test coverage lives in 🤖 Verified and closed by Claude Code |
Extends the
MiniMaxProfile.build_api_kwargs_extrasprovider plugin to recognize MiniMax's Anthropic-compatible/anthropicendpoint atapi.minimax.io/anthropic, in addition to the existingapi.minimax.io/v1OpenAI-compatible route.Why this is separate from #66694
#66694 (
fix(minimax): preserve M3 adaptive thinking on Anthropic routes) covers the Anthropic adapter layer — the request kwargs that go out as Anthropicthinking: {"type": "adaptive"}on theauxiliary_clientadapter path. That's correct and stays open.This PR covers the provider plugin layer — the
extra_bodythat goes out on the OpenAI-compatible request shape that MiniMax's/anthropicendpoint also accepts. Different code path, different kwargs structure.The bug
On the
/anthropicendpoint, omittingthinkingcauses MiniMax-M3 to default to OFF (per MiniMax docs). Previously, the provider plugin only matched/v1, so requests to/anthropicgot an emptyextra_bodyand M3 returned thinking as disabled.The fix
Add
_is_minimax_global_anthropic_base_url()helper that matchesapi.minimax.io/anthropic. Updatebuild_api_kwargs_extrasto:/v1and/anthropic(the existing/v1condition becomes an OR with the new/anthropiccondition).reasoning_split=Trueonly on/v1(the/anthropicendpoint already returns thinking as native content blocks, no split flag needed).thinking: {type: adaptive}(ordisabledif reasoning is explicitly disabled) on both routes.Out of scope
The
/anthropicroute also requires stateful replay preservation across multi-turn tool calls, which is the focus of the Anthropic adapter work in #66694. The provider plugin here only handles the request-shape kwargs.