fix: align MiniMax provider with official API docs#7096
Closed
kshitijk4poor wants to merge 2 commits into
Closed
Conversation
b48523f to
c7022c4
Compare
- Fix providers.py transport: minimax/minimax-cn use anthropic_messages, not openai_chat. determine_api_mode() now returns the correct api_mode for /model switch and other codepaths that resolve by provider name. - Fix context window: 204,800 tokens per official docs, not 1M/1.05M. Removes stale M1 per-variant entries; single 'minimax' prefix entry. - Enable thinking: MiniMax officially supports the thinking parameter (manual mode with budget_tokens). Removes the guard that blocked it. - Add max output entry: 131,072 tokens in _ANTHROPIC_OUTPUT_LIMITS (source: OpenClaw model definitions, confirmed via API behavior). - Update model catalog: M2.7, M2.5, M2.1, M2 per official Anthropic endpoint docs. Removes M1 family (not on /anthropic endpoint). - Add tests: determine_api_mode(), max output limits, thinking support. Updates existing tests to match official docs. Source: https://platform.minimax.io/docs/api-reference/text-anthropic-api
c7022c4 to
5190cc8
Compare
…reeze When context compaction fires during a streamed conversation, the compression LLM call would edit the same Telegram message as the agent's response. After compaction completed, the stream consumer still held state pointing at the old message, causing subsequent edits to fail and the chat to appear "stuck" or never finish. Fix: after compression, reset the stream consumer's accumulated text, message ID, and fallback state. The next API response streams to a fresh Telegram message instead of fighting over the old one. Also wire _stream_consumer_instance from the gateway's stream_consumer holder into the agent so _compress_context can access it. Cherry-picked from PR NousResearch#7426 by @dangelo352.
Contributor
|
Merged via PR #7126. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for the thorough MiniMax alignment work — all 6 bugs fixed, context windows corrected, and 39 tests added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns the MiniMax provider implementation with official API documentation. Fixes 6 bugs — transport mismatch, credential leak, prompt caching leak, dot-to-hyphen model name corruption, trajectory compressor URL routing, and stale doctor health check — plus corrects context window, thinking support, max output, and model catalog to match the actual API.
Primary reference: Compatible Anthropic API — MiniMax API Docs
Changes
Bug fix: transport mismatch in
providers.pyHERMES_OVERLAYShadtransport="openai_chat"for minimax/minimax-cn, but MiniMax's/anthropicendpoint speaks the Anthropic Messages wire format. This causeddetermine_api_mode("minimax")to return"chat_completions"instead of"anthropic_messages", breaking/modelswitch and any codepath that resolves api_mode by provider name.Bug fix: credential leak in
switch_model()switch_model()fell back toresolve_anthropic_token()for ALLanthropic_messagesproviders. The__init__path (line 761) correctly guards with_is_native_anthropic = self.provider == "anthropic"—switch_model()now mirrors that guard.Bug fix: prompt caching sent to MiniMax
is_native_anthropicwas set fromapi_mode == "anthropic_messages"alone. This caused Anthropic prompt cachingcache_controlbreakpoints to be injected into requests to MiniMax. Fixed in__init__,switch_model(), and fallback activation to requireprovider == "anthropic".Bug fix: dot-to-hyphen corruption in
_anthropic_preserve_dots()MiniMax model IDs contain dots (e.g.
MiniMax-M2.7). The Anthropic adapter'snormalize_model_name()converts dots to hyphens by default (MiniMax-M2.7→MiniMax-M2-7), causing model-not-found errors. Addedminimax/minimax-cnto the preserve-dots provider set.Bug fix: trajectory compressor URL routing
Passed raw
/anthropicURL to OpenAI SDK →/anthropic/chat/completions(404). Now uses the canonical_to_openai_base_url()helper fromauxiliary_client.py.Improvement: doctor health check for MiniMax
Previously skipped ("key configured" without testing connectivity). Now uses MiniMax's OpenAI-compat
/v1/modelsendpoint with/anthropic→/v1rewrite via_to_openai_base_url().Context window: 204,800 tokens
Previous values were 1,000,000 (M1 variants) and 1,048,576 (M2 variants) — both wrong.
Thinking support: enabled (manual mode)
The previous guard blocked
thinkingfor all MiniMax models. MiniMax now correctly gets manual thinking (type: "enabled"+budget_tokens), not adaptive thinking (Claude 4.6-only).Max output tokens: 131,072
Added explicit entry in
_ANTHROPIC_OUTPUT_LIMITS. Previous behavior fell back to the generic 128K default.Model catalog: M2.7, M2.5, M2.1, M2
Replaced M1 family (not available on
/anthropicendpoint) with the actual supported models. Highspeed variants exist but are omitted from the default picker (users can specify them manually).Files changed (10)
hermes_cli/providers.pytransport="anthropic_messages"for minimax/minimax-cnagent/anthropic_adapter.py_ANTHROPIC_OUTPUT_LIMITS; remove thinking guardagent/model_metadata.py"minimax": 204800single prefix entryhermes_cli/models.pyhermes_cli/setup.pyrun_agent.pyprovider == "anthropic"), dot preservationtrajectory_compressor.py_to_openai_base_url()for client inithermes_cli/doctor.py/v1/modelstests/agent/test_minimax_provider.pytests/hermes_cli/test_setup_model_selection.pyTest results