feat: add MiniMax provider with M3 as default - #185
Conversation
- Add `minimax` as a new LLM provider alongside `anthropic` and `openai` (MiniMax is OpenAI-compatible, so the existing OpenAI codepaths now also serve it via a new provider_is_openai_compat() helper) - Default MiniMax model is `MiniMax-M3` (current generation); `MiniMax-M2.7` and `MiniMax-M2.7-highspeed` are exposed as alternatives - New constants in mimi_config.h: MIMI_MINIMAX_API_URL, MIMI_MINIMAX_DEFAULT_MODEL, MIMI_MINIMAX_MODEL_M27, MIMI_MINIMAX_MODEL_M27_HS - Update CLI help, web onboarding provider dropdown, secrets example, and EN/CN/JA READMEs
📝 WalkthroughWalkthroughThis PR adds MiniMax as a supported LLM provider by defining its configuration constants, treating it as OpenAI-compatible in the request/response proxy layer, and exposing provider selection through CLI, web UI, and documentation in three languages. ChangesMiniMax LLM Provider Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)main/llm/llm_proxy.cIn file included from main/llm/llm_proxy.c:1: ... [truncated 729 characters] ... pt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include" main/cli/serial_cli.cIn file included from main/cli/serial_cli.c:1: ... [truncated 733 characters] ... t/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include" 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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
main/llm/llm_proxy.c (1)
315-334:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winValidate
snprintfresult before writing proxy headers to avoid OOB read.Line 316/325 assigns
hlen = snprintf(...), but Line 336 writeshlenbytes even whensnprintftruncates (hlen >= sizeof(header)). That can read pastheaderbounds.Proposed fix
- if (provider_is_openai_compat()) { - hlen = snprintf(header, sizeof(header), + if (provider_is_openai_compat()) { + hlen = snprintf(header, sizeof(header), "POST %s HTTP/1.1\r\n" "Host: %s\r\n" "Content-Type: application/json\r\n" "Authorization: Bearer %s\r\n" "Content-Length: %d\r\n" "Connection: close\r\n\r\n", llm_api_path(), llm_api_host(), s_api_key, body_len); } else { hlen = snprintf(header, sizeof(header), "POST %s HTTP/1.1\r\n" "Host: %s\r\n" "Content-Type: application/json\r\n" "x-api-key: %s\r\n" "anthropic-version: %s\r\n" "Content-Length: %d\r\n" "Connection: close\r\n\r\n", llm_api_path(), llm_api_host(), s_api_key, MIMI_LLM_API_VERSION, body_len); } + if (hlen < 0 || hlen >= (int)sizeof(header)) { + proxy_conn_close(conn); + return ESP_ERR_INVALID_SIZE; + }🤖 Prompt for 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. In `@main/llm/llm_proxy.c` around lines 315 - 334, snprintf() return (hlen) must be validated before using it to write header bytes: check if hlen < 0 or hlen >= sizeof(header) and handle as an error (or clamp) instead of blindly writing hlen bytes; update the code around the header construction (the two snprintf calls that set hlen and the subsequent write that uses hlen) to detect truncation or failures and either fail gracefully or set hlen = sizeof(header)-1 after ensuring header is NUL-terminated so you never read/write past the header buffer.
🤖 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.
Outside diff comments:
In `@main/llm/llm_proxy.c`:
- Around line 315-334: snprintf() return (hlen) must be validated before using
it to write header bytes: check if hlen < 0 or hlen >= sizeof(header) and handle
as an error (or clamp) instead of blindly writing hlen bytes; update the code
around the header construction (the two snprintf calls that set hlen and the
subsequent write that uses hlen) to detect truncation or failures and either
fail gracefully or set hlen = sizeof(header)-1 after ensuring header is
NUL-terminated so you never read/write past the header buffer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dad8f194-91d4-4ac1-baf9-ada16d54c63c
📒 Files selected for processing (8)
README.mdREADME_CN.mdREADME_JA.mdmain/cli/serial_cli.cmain/llm/llm_proxy.cmain/mimi_config.hmain/mimi_secrets.h.examplemain/onboard/onboard_html.h
Summary
Add a third LLM provider option —
minimax— alongside the existinganthropicandopenaichoices, withMiniMax-M3as the default model.MimiClaw previously had no MiniMax integration at all. This PR adds one by
treating MiniMax as OpenAI-compatible (it exposes
https://api.minimax.io/v1/chat/completionswith the standardBearerauth scheme), and routing the request/response through the existing
OpenAI codepaths.
Changes
MIMI_MINIMAX_API_URLinmain/mimi_config.h,plus
MIMI_MINIMAX_DEFAULT_MODEL(MiniMax-M3),MIMI_MINIMAX_MODEL_M27(MiniMax-M2.7),MIMI_MINIMAX_MODEL_M27_HS(MiniMax-M2.7-highspeed).provider_is_minimax()+provider_is_openai_compat()helpersin
main/llm/llm_proxy.c. Every existing OpenAI branch inllm_proxy.c(auth header, request body field name, message conversion, tool-use
response parsing) now uses the
_compatpredicate so MiniMax flowsthrough the same code without duplicating it.
main/onboard/onboard_html.h) — adds aminimaxoption to the provider dropdown.main/cli/serial_cli.c) — updates theset_model_providerhelp text to includeminimax.mimi_secrets.h.example— documents the three new model IDs andshows how to switch to MiniMax from the serial CLI.
and CLI example all reflect the new
minimaxoption.The default provider is still
anthropic(no behavior change for existingusers); MiniMax is opt-in.
Why MiniMax
output, image input support, OpenAI-compatible API — a natural fit for
MimiClaw's existing OpenAI codepath with no extra protocol layer.
MiniMax-M2.7/M2.7-highspeed)available as a drop-in alternative.
Testing
ESP-IDF dependencies and asserts:
provider=anthropic→MIMI_LLM_API_URLprovider=openai→MIMI_OPENAI_API_URLprovider=minimax→MIMI_MINIMAX_API_URLprovider_is_openai_compat()is true foropenaiandminimax,false for
anthropic.idf.py buildrequires the ESP-IDF v5.5+ toolchain (not availablein this environment); the project's CI workflow
(
.github/workflows/build.yml) will exercise the real build.Summary by CodeRabbit
Release Notes
New Features
Documentation