feat: add MiniMax as native LLM provider with M2.7 default#4843
feat: add MiniMax as native LLM provider with M2.7 default#4843octo-patch wants to merge 3 commits intocrewAIInc:mainfrom
Conversation
Add first-class support for MiniMax's OpenAI-compatible API, enabling users to use MiniMax-M2.5 and MiniMax-M2.5-highspeed models natively without requiring the LiteLLM fallback. Changes: - Add MiniMaxCompletion provider (llms/providers/minimax/) - Register MiniMax models in constants and routing logic - Add MiniMax to CLI provider selection - Document MiniMax usage in README Usage: export MINIMAX_API_KEY="your-key" llm = LLM(model="MiniMax-M2.5")
| return self._finalize_streaming( | ||
| full_response, tool_calls, usage_data, params, | ||
| available_functions, from_task, from_agent, | ||
| ) |
There was a problem hiding this comment.
Missing after-LLM-call hooks in sync streaming path
Medium Severity
The sync streaming path (_handle_streaming → _finalize_streaming) returns the text response directly without calling _invoke_after_llm_call_hooks. The sync non-streaming path in the same file (_handle_completion) does call this hook. The OpenAI provider's equivalent streaming path also calls it (wrapping the finalized string result in _invoke_after_llm_call_hooks before returning). This means registered after_llm_call hooks silently won't fire for sync streaming MiniMax calls.
Additional Locations (1)
| if temperature is not None and temperature <= 0: | ||
| temperature = 0.01 | ||
| if temperature is None: | ||
| temperature = 1.0 |
There was a problem hiding this comment.
Temperature values above 1.0 not clamped or validated
Low Severity
The code clamps temperature values ≤ 0 to 0.01 to satisfy MiniMax's (0.0, 1.0] constraint, but values > 1.0 are silently passed through to the API, which will reject them. Since the code already partially validates this constraint, the upper bound check appears to be an oversight.
Add 11 unit tests covering MiniMax provider routing, model selection, base URL configuration, temperature clamping, and API key validation.
2c98147 to
53fcad6
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 4 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| except Exception as e: | ||
| if is_context_length_exceeded(e): | ||
| raise LLMContextLengthExceededError(str(e)) from e | ||
| raise |
There was a problem hiding this comment.
Async completion missing specific error handling present in sync
Medium Severity
The _ahandle_completion async method only has a generic Exception handler, while its sync counterpart _handle_completion explicitly catches NotFoundError (converting to ValueError) and APIConnectionError (converting to ConnectionError) with specific error messages and failed-event emissions. This means callers of acall() receive raw OpenAI SDK exception types (NotFoundError, APIConnectionError) while callers of call() receive standard Python exceptions (ValueError, ConnectionError). The OpenAI provider handles both exception types in its async path, making MiniMax inconsistent with both itself and other providers.
Additional Locations (1)
| return int(size * CONTEXT_WINDOW_USAGE_RATIO) | ||
|
|
||
| def supports_multimodal(self) -> bool: | ||
| return False |
There was a problem hiding this comment.
MiniMax provider largely duplicates OpenAI provider code
Low Severity
MiniMaxCompletion is ~720 lines that closely mirror OpenAICompletion since MiniMax uses an OpenAI-compatible API with the same SDK. Methods like _extract_token_usage, _finalize_streaming, _handle_completion, _ahandle_completion, and the streaming handlers are near-identical to their OpenAI counterparts. This duplication increases the maintenance burden — any bug fix in shared logic (e.g., tool-call handling, streaming finalization) needs to be applied in both files independently.
- Add MiniMax-M2.7 and MiniMax-M2.7-highspeed to model list - Set MiniMax-M2.7 as default model - Keep all previous models (M2.5, M2.5-highspeed) as alternatives - Update CLI model selection, context window mappings, and constants - Update tests to cover M2.7 models and verify ordering - Update README with M2.7 as recommended model
|
This PR is stale because it has been open for 45 days with no activity. |


Summary
Add first-class support for MiniMax as a native LLM provider in CrewAI, enabling users to use MiniMax models without the LiteLLM fallback.
What's included
crewai/llms/providers/minimax/) — uses the OpenAI-compatible SDK pointed at MiniMax's API endpointMiniMax-M2.5andMiniMax-M2.5-highspeedare recognized automatically by the factory, supporting bare model names,minimax/prefix, and explicitprovider="minimax"kwargtemperatureclamped to(0.0, 1.0](zero is rejected by MiniMax API)response_formatintentionally omitted (not supported)https://api.minimax.io/v1Usage
Models
MiniMax-M2.5MiniMax-M2.5-highspeedTest plan
pytest lib/crewai/tests/llms/minimax/)LLM(model="MiniMax-M2.5")routes toMiniMaxCompletionminimax/MiniMax-M2.5prefix routing works correctlyhttps://api.minimax.io/v1Note
Medium Risk
Adds a new native LLM provider and updates model-routing logic, which could affect how
LLM()selects providers and handles streaming/tool calls for prefixed models. Risk is mitigated by targeted unit tests but still touches core LLM factory behavior.Overview
Adds native MiniMax LLM support so
LLM(model="MiniMax-M2.7")(orminimax/-prefixed models /provider="minimax") routes to a first-class provider instead of falling back to LiteLLM.Updates CLI/provider constants to include
minimax, prompt forMINIMAX_API_KEY, and registers MiniMax models; extendsLLMprovider inference/validation, supported native providers, and context window sizing for MiniMax.Introduces
MiniMaxCompletion(OpenAI-SDK-based) with MiniMax-specific behaviors (default base URL, temperature clamping, noresponse_format), plus unit tests and a README usage snippet.Written by Cursor Bugbot for commit 6b1f148. This will update automatically on new commits. Configure here.