Add MiniMax M3 provider metadata#276
Conversation
📝 WalkthroughWalkthroughMiniMax 集成将默认模型从 M2.7 切换为 M3,扩展模型元数据和区域端点文档,更新 API/OAuth 入站配置,并新增 M3 thinking 流载荷兼容处理及测试。 ChangesMiniMax M3 支持
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant EmbeddedRunner
participant M3ThinkingWrapper
participant MiniMaxAnthropicStream
EmbeddedRunner->>M3ThinkingWrapper: 包装 MiniMax M3 的 streamFn
M3ThinkingWrapper->>MiniMaxAnthropicStream: 转发流请求
MiniMaxAnthropicStream-->>M3ThinkingWrapper: 返回 thinking.type=enabled
M3ThinkingWrapper-->>EmbeddedRunner: 返回 thinking.type=adaptive
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/agents/pi-embedded-runner/extra-params.ts (1)
371-378: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value建议添加 debug 日志以保持与其他条件包装器的一致性。
同函数中大多数条件包装器(如 SiliconFlow L331-333、Bedrock L361-363、Anthropic fast mode L382-384、MiniMax fast mode L389-391)都包含
log.debug调用。M3 thinking 包装器是条件性的且与 provider/modelId 相关,添加日志有助于排查 M3 兼容包装是否被正确应用。♻️ 建议添加 debug 日志
if ( shouldApplyMinimaxM3ThinkingCompat({ provider: ctx.provider, modelId: ctx.modelId, }) ) { + log.debug( + `applying MiniMax M3 thinking compat wrapper for ${ctx.provider}/${ctx.modelId}`, + ); ctx.agent.streamFn = createMinimaxM3ThinkingWrapper(ctx.agent.streamFn); }🤖 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 `@src/agents/pi-embedded-runner/extra-params.ts` around lines 371 - 378, 在应用 createMinimaxM3ThinkingWrapper 的条件分支中添加与其他条件包装器一致的 log.debug 调用,记录 provider、modelId 及 M3 thinking 兼容包装已应用;保持现有 shouldApplyMinimaxM3ThinkingCompat 判断和包装逻辑不变。src/agents/pi-embedded-runner/minimax-stream-wrappers.ts (1)
29-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value建议添加简要注释说明 thinking 归一化逻辑。
{ type: "enabled", budget_tokens }被替换为{ type: "adaptive" }时会丢弃budget_tokens等额外字段。虽然测试确认了该行为,但此处属于不太直观的兼容性改写,添加一行注释有助于后续维护者理解为何要丢弃budget_tokens。As per coding guidelines:
**/*.{ts,tsx}: Add brief code comments for tricky or non-obvious logic♻️ 建议添加注释
return streamWithPayloadPatch(underlying, model, context, options, (payloadObj) => { const thinking = payloadObj.thinking; if ( thinking && typeof thinking === "object" && !Array.isArray(thinking) && (thinking as Record<string, unknown>).type === "enabled" ) { + // MiniMax M3 uses "adaptive" thinking; drop budget_tokens since adaptive mode manages it automatically. payloadObj.thinking = { type: "adaptive" }; } });🤖 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 `@src/agents/pi-embedded-runner/minimax-stream-wrappers.ts` around lines 29 - 39, 在 streamWithPayloadPatch 的 payloadObj 处理回调中,为将 thinking 的 enabled 形式归一化为 adaptive 的赋值逻辑添加一行简短注释,明确说明该兼容性改写会丢弃 budget_tokens 等额外字段;不要修改现有转换行为。Source: Coding guidelines
src/agents/pi-embedded-runner/minimax-stream-wrappers.test.ts (1)
25-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win建议补充关键边界测试用例。
当前测试覆盖了主要路径,但缺少以下边界场景:
- 非 anthropic-messages API 的 M3 模型:
createMinimaxM3ThinkingWrapper在 L23 有model.api !== "anthropic-messages"守卫,但无测试覆盖。如果该守卫被意外移除,测试无法捕获。- 非 minimax provider 的 M3 modelId:
shouldApplyMinimaxM3ThinkingCompat的 provider 守卫缺少反向测试(如provider: "openai"+modelId: "MiniMax-M3"应返回false)。- 已是 adaptive 的 thinking:测试 idempotency,确保
{ type: "adaptive" }不会被重复改写。♻️ 建议补充的测试用例
it("does not patch non-anthropic-messages API payloads", () => { expect( captureThinkingPayload({ api: "openai", provider: "minimax", id: "MiniMax-M3", } as Parameters<StreamFn>[0]), ).toEqual({ thinking: { type: "enabled", budget_tokens: 1024 } }); }); it("rejects M3 modelId on non-minimax providers", () => { expect( shouldApplyMinimaxM3ThinkingCompat({ provider: "openai", modelId: "MiniMax-M3" }), ).toBe(false); }); it("leaves already-adaptive thinking unchanged", () => { let captured: unknown; const underlying: StreamFn = (payloadModel, _context, options) => { const payload = { thinking: { type: "adaptive" } }; options?.onPayload?.(payload, payloadModel); captured = payload; return {} as ReturnType<StreamFn>; }; void createMinimaxM3ThinkingWrapper(underlying)( { api: "anthropic-messages", provider: "minimax", id: "MiniMax-M3" } as Parameters<StreamFn>[0], { messages: [] } as Parameters<StreamFn>[1], {} as Parameters<StreamFn>[2], ); expect(captured).toEqual({ thinking: { type: "adaptive" } }); });🤖 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 `@src/agents/pi-embedded-runner/minimax-stream-wrappers.test.ts` around lines 25 - 60, Extend the minimax stream wrapper tests with boundary coverage: verify captureThinkingPayload leaves a MiniMax-M3 payload unchanged for non-anthropic-messages APIs, verify shouldApplyMinimaxM3ThinkingCompat returns false for MiniMax-M3 on non-minimax providers, and verify createMinimaxM3ThinkingWrapper preserves an already-adaptive thinking payload without rewriting it.
🤖 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 `@extensions/minimax/model-definitions.ts`:
- Line 43: 更新 buildMinimaxModelDefinition 中 input 的回退逻辑:未传入 params.input
时,优先使用对应 catalog 项的 input,只有 catalog?.input 也不存在时才回退为 ["text"];保留显式 params.input
的现有行为。
---
Nitpick comments:
In `@src/agents/pi-embedded-runner/extra-params.ts`:
- Around line 371-378: 在应用 createMinimaxM3ThinkingWrapper 的条件分支中添加与其他条件包装器一致的
log.debug 调用,记录 provider、modelId 及 M3 thinking 兼容包装已应用;保持现有
shouldApplyMinimaxM3ThinkingCompat 判断和包装逻辑不变。
In `@src/agents/pi-embedded-runner/minimax-stream-wrappers.test.ts`:
- Around line 25-60: Extend the minimax stream wrapper tests with boundary
coverage: verify captureThinkingPayload leaves a MiniMax-M3 payload unchanged
for non-anthropic-messages APIs, verify shouldApplyMinimaxM3ThinkingCompat
returns false for MiniMax-M3 on non-minimax providers, and verify
createMinimaxM3ThinkingWrapper preserves an already-adaptive thinking payload
without rewriting it.
In `@src/agents/pi-embedded-runner/minimax-stream-wrappers.ts`:
- Around line 29-39: 在 streamWithPayloadPatch 的 payloadObj 处理回调中,为将 thinking 的
enabled 形式归一化为 adaptive 的赋值逻辑添加一行简短注释,明确说明该兼容性改写会丢弃 budget_tokens
等额外字段;不要修改现有转换行为。
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d40cdd2d-0082-4336-b392-1b0da346f079
📒 Files selected for processing (14)
docs/providers/minimax.mdextensions/minimax/index.tsextensions/minimax/model-definitions.test.tsextensions/minimax/model-definitions.tsextensions/minimax/onboard.test.tsextensions/minimax/onboard.tsextensions/minimax/openclaw.plugin.jsonextensions/minimax/provider-catalog.tsextensions/minimax/provider-models.tssrc/agents/models-config.providers.minimax.test.tssrc/agents/pi-embedded-runner/extra-params.tssrc/agents/pi-embedded-runner/minimax-stream-wrappers.test.tssrc/agents/pi-embedded-runner/minimax-stream-wrappers.tssrc/plugins/bundled-plugin-metadata.generated.ts
| reasoning: params.reasoning ?? catalog?.reasoning ?? false, | ||
| input: ["text"], | ||
| cost: params.cost, | ||
| input: params.input ? [...params.input] : ["text"], |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
input 回退逻辑与 name/reasoning 不一致。
buildMinimaxModelDefinition 中,name 和 reasoning 在未传入时会回退到 catalog 值,但 input 直接默认为 ["text"],未检查 catalog?.input。若直接调用此函数并传入 catalog 中已有的模型 ID(如 "MiniMax-M3")但未传 input,将得到 ["text"] 而非 ["text", "image"]。
🔧 建议修复:使 `input` 回退到 catalog
- input: params.input ? [...params.input] : ["text"],
+ input: [...(params.input ?? catalog?.input ?? ["text"])],📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| input: params.input ? [...params.input] : ["text"], | |
| input: [...(params.input ?? catalog?.input ?? ["text"])], |
🤖 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 `@extensions/minimax/model-definitions.ts` at line 43, 更新
buildMinimaxModelDefinition 中 input 的回退逻辑:未传入 params.input 时,优先使用对应 catalog 项的
input,只有 catalog?.input 也不存在时才回退为 ["text"];保留显式 params.input 的现有行为。
Summary
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
MiniMax M3 becomes the recommended default for API-key and Token Plan onboarding. MiniMax M2.7 and MiniMax M2.7 Highspeed remain available. The provider guide now lists global and CN endpoints for both Anthropic-compatible and OpenAI-compatible clients.
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: None.Repro + Verification
Environment
Steps
extensions/minimax/openclaw.plugin.json.Expected
adaptive, and generated metadata matches the canonical manifest.Actual
Evidence
Verification results:
extensions/minimax/model-definitions.test.tsandextensions/minimax/onboard.test.ts: 17 tests passed.src/agents/pi-embedded-runner/minimax-stream-wrappers.test.ts: 3 tests passed.Human Verification (required)
Review Conversations
Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
minimax/MiniMax-M2.7explicitly or revert the commit.Risks and Mitigations