fix: add mergeToolResultText for Mistral/Devstral models in OpenRouter#10630
fix: add mergeToolResultText for Mistral/Devstral models in OpenRouter#10630roomote[bot] wants to merge 2 commits intomainfrom
Conversation
Review complete. No issues found. The change correctly extends Mistral model detection to include Devstral models and adds Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
@roomote What are the next steps to merge this? |
The PR was in draft status. I've marked it as ready for review. The code changes look good - the fix extends Mistral model detection to include Devstral models and adds Next steps: A maintainer can now review and merge this PR. |
Review complete. No issues found. The change correctly extends Mistral model detection to include Devstral models and adds Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
Please fix and merge this, Devstral 2512 is still not working in recent Roo code |
|
I do still get: `Date/time: 2026-02-20T18:55:54.621Z Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.` What are next steps to fix it? |
Rebased the PR branch on main (was 370 commits behind) and added tests for Mistral/Devstral model detection with Note to @PeterSmarthome: The error you're seeing on v3.50.2 is expected because this PR hasn't been merged yet. Once merged, |
Fixes the "Unexpected role user after role tool" error for Mistral and Devstral models when using OpenRouter. Changes: - Extended model detection to include "devstral" (e.g. mistralai/devstral-2512) - Added mergeToolResultText: true to merge text content into tool messages instead of creating a separate user message that violates Mistral ordering Closes #10618
…ext and rebase on main
ce38fd4 to
cb3f1e0
Compare
Related GitHub Issue
Closes: #10618
Related: #10540 (same root cause, different provider)
Description
This PR attempts to address Issue #10618. Feedback and guidance are welcome.
Root Cause:
The error "Unexpected role 'user' after role 'tool'" occurs because Mistral/Devstral models have strict message ordering requirements. After a
toolrole message, the next message cannot be auserrole message.Solution:
mistralai/devstral-2512contains "devstral" not "mistral")mergeToolResultText: trueto the conversion options, which merges text content (like environment_details) into the last tool message instead of creating a separate user messageThis uses the same
mergeToolResultTextmechanism that PR #10598 exposes as a setting for OpenAI Compatible providers, but applies it automatically for Mistral family models in OpenRouter since we can detect them by model ID.Test Procedure
mistralai/devstral-2512)mergeToolResultTexttests inopenai-format.spec.tscover the underlying functionalityPre-Submission Checklist
mergeToolResultTextfunctionality is already tested.Documentation Updates
Additional Notes
This is a minimal fix that leverages existing infrastructure. The
mergeToolResultTextoption was added in a previous PR and is already used by DeepSeek, Z.ai, and MiniMax providers for similar message ordering issues.Important
Fixes message ordering error for Mistral/Devstral models in
OpenRouterHandlerby merging tool result text and extending model detection.OpenRouterHandlerby merging tool result text.createMessage()inopenrouter.tsto usemergeToolResultTextfor Mistral/Devstral models.modelIdfor "mistral" or "devstral" to apply the fix.mergeToolResultTexttests inopenai-format.spec.ts.This description was created by
for ce38fd4. You can customize this summary. It will automatically update as commits are pushed.
Start a new Roo Code Cloud session on this branch