mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: add mergeToolResultText for Mistral/Devstral models in OpenRouter
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
This commit is contained in:
parent
44fd975b17
commit
76091b3245
1 changed files with 7 additions and 3 deletions
|
|
@ -232,13 +232,17 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
}
|
||||
|
||||
// Convert Anthropic messages to OpenAI format.
|
||||
// Pass normalization function for Mistral compatibility (requires 9-char alphanumeric IDs)
|
||||
const isMistral = modelId.toLowerCase().includes("mistral")
|
||||
// Pass normalization function for Mistral/Devstral compatibility (requires 9-char alphanumeric IDs)
|
||||
// Also merge tool result text to avoid "Unexpected role 'user' after role 'tool'" errors
|
||||
const modelIdLower = modelId.toLowerCase()
|
||||
const isMistralFamily = modelIdLower.includes("mistral") || modelIdLower.includes("devstral")
|
||||
let openAiMessages: OpenAI.Chat.ChatCompletionMessageParam[] = [
|
||||
{ role: "system", content: systemPrompt },
|
||||
...convertToOpenAiMessages(
|
||||
messages,
|
||||
isMistral ? { normalizeToolCallId: normalizeMistralToolCallId } : undefined,
|
||||
isMistralFamily
|
||||
? { normalizeToolCallId: normalizeMistralToolCallId, mergeToolResultText: true }
|
||||
: undefined,
|
||||
),
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue