fix(core): sanitize Mistral reasoning content - #3934
Conversation
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — deepseek-v4-pro via Qwen Code /review
tanzhenxin
left a comment
There was a problem hiding this comment.
Review
Thanks for the fix! Unfortunately #3882 landed a few hours before this and addresses the same issue (#3304) with the same approach — a dedicated Mistral provider that strips reasoning_content from outbound messages, detected by official base URL plus model-name fallback. The file layout, detection logic, and test shape are essentially identical.
Closing this in favor of the merged PR seems like the right call. Really appreciate the careful work here — the root-cause writeup and validation steps were great. Hope you'll take another swing at something else soon.
Verdict
COMMENT — duplicate of merged #3882; no action needed on this PR.
Fixes #3304
Summary
reasoning_contentfrom assistant messages before the provider call.buildRequest().Root Cause
When users switch from a reasoning model to Mistral in the same session, previous assistant turns can contain
reasoning_content. Mistral's strict OpenAI-compatible API rejects that non-standard message field, while Qwen Code was forwarding the shared history unchanged.Validation
npm run test --workspace=packages/core -- src/core/openaiContentGenerator/provider/mistral.test.ts -t reasoning_contentnpm run test --workspace=packages/core -- src/core/openaiContentGenerator/provider/mistral.test.ts src/core/openaiContentGenerator/provider/deepseek.test.tsnpm run lint --workspace=packages/corenpm run typecheck --workspace=packages/corenpx prettier --check packages/core/src/core/openaiContentGenerator/provider/mistral.ts packages/core/src/core/openaiContentGenerator/provider/mistral.test.ts packages/core/src/core/openaiContentGenerator/provider/index.ts packages/core/src/core/openaiContentGenerator/index.ts