fix(core): handle MiMo tool-result media#4281
Conversation
📋 Review SummaryThis PR introduces a new MiMo OpenAI-compatible provider that addresses two specific issues with the MiMo API: (1) preserving 🔍 General Feedback
🎯 Specific Feedback🟡 High Priority
function ensureReasoningContentOnToolCalls(
message: OpenAI.Chat.ChatCompletionMessageParam,
): OpenAI.Chat.ChatCompletionMessageParam {
// ... logic ...
return {
...assistant,
reasoning_content: '',
} as OpenAI.Chat.ChatCompletionMessageParam; // This cast drops reasoning_content from the type
}Suggested fix: Either return 🟢 Medium Priority
const providerOverrides =
this.config.provider.getRequestContextOverrides?.() ?? {};
// Consider: const providerOverrides: OpenAIRequestContextOverrides =
// this.config.provider.getRequestContextOverrides?.() ?? {};🔵 Low Priority
getRequestContextOverrides(): { splitToolMedia?: boolean } {
// Respect explicit user configuration; default to true for MiMo compatibility
return {
splitToolMedia: this.contentGeneratorConfig.splitToolMedia ?? true,
};
}
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
| createCliConfig(), | ||
| ); | ||
|
|
||
| expect(provider).toBeInstanceOf(MiMoOpenAICompatibleProvider); |
There was a problem hiding this comment.
[Suggestion] Missing test for determineProvider ordering when both MiMo model name and OpenRouter hostname match.
A user configuring baseUrl: 'https://openrouter.ai/api/v1' + model: 'mimo-v2.5-pro' currently gets the MiMo provider (checked before OpenRouter in determineProvider). No test asserts this priority. If someone later reorders the checks, users routing MiMo models through OpenRouter would silently get the wrong provider — losing reasoning_content injection and splitToolMedia: true.
Consider adding:
it('is selected over OpenRouter when both hostname and model match', () => {
const provider = determineProvider(
createProviderConfig({
baseUrl: 'https://openrouter.ai/v1',
model: 'mimo-v2.5-pro',
}),
createCliConfig(),
);
expect(provider).toBeInstanceOf(MiMoOpenAICompatibleProvider);
});— qwen-latest-series-invite-beta-v34 via Qwen Code /review
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — qwen-latest-series-invite-beta-v34 via Qwen Code /review
Maintainer test report — PR #4281Built and validated locally in a dedicated Environment
Results
Pre-existing failure (NOT caused by this PR)Reproduced on a clean worktree of Behavioral checks against the diff
Risk assessmentLow risk for merge.
Not covered locally
Reproducegit fetch origin pull/4281/head:pr-4281 && git checkout pr-4281
npm install
cd packages/core && npx vitest run \
src/core/openaiContentGenerator/provider/mimo.test.ts \
src/core/openaiContentGenerator/pipeline.test.ts
cd ../.. && npm run typecheckRecommendation: safe to merge once at least one reviewer signs off on the |
Summary
role: \"tool\"messages.400 Param Incorrectwhen tool-call history omitsreasoning_content, and strict chat-completions servers can also reject image/video/file content embedded directly in tool result messages.splitToolMediadefault for MiMo, and the request-context override precedence.Validation
1f1a7c9d-f054-46fd-8458-1717cd611968, where the user asked Qwen Code to read any repository image andread_filereturned a PNG as inline media.reasoning_contentfor assistant tool-call turns.packages/coretypecheck passed.read_fileand verify the follow-up request no longer fails with400 Param Incorrect.read_filereturninginlineDataforicon-orange.png, followed immediately byqwen-code.api_error status=400 model=mimo-v2.5 msg=400 Param Incorrect.Scope / Risk
splitToolMedia: falseto opt out.Testing Matrix
Testing matrix notes:
npx vitestandpackages/corenpm run typecheck.npm run typecheckwas attempted but is currently blocked by unrelated existingpackages/cli/src/serve/workspaceAgents.tsandworkspaceMemory.tstype errors.Linked Issues / Bugs
Fixes #4223