You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mistral API error with Devstral via LiteLLM: "Expected last role User or Tool (or Assistant with prefix True)" #19115
When using Devstral (Mistral model) via LiteLLM with @ai-sdk/openai-compatible,
Mistral returns error 3230: "Expected last role User or Tool (or Assistant with prefix True)"
(Opencode diagnosed this itself with devstral model base on the 1.3.2 codebase)
The issue occurs because:
Agent performs tool calls (ends with tool role)
Agent continues with assistant message (no user after)
Mistral expects either a user/tool message OR an assistant with prefix=true
OpenCode's Mistral transformation (transform.ts lines 90-134) handles tool→user
transitions but NOT assistant→(end) transitions.
Expected: OpenCode should either insert a continuation user message OR add
prefix:true to the last assistant message when sending to Mistral.
Stuff works if I am using the mistral provider explicitly, but then the token usage (context) is not working.
So basically 2 routes to resolution for me: either mistral provider can deal with the context / cost informations from litellm (like openai provider) or the openai provider is able to fix this ordering issue for models which have mistral / devstral in its name
Activity
github-actions commentedon Mar 25, 2026
This issue might be a duplicate of existing issues. Please check:
nanosek commentedon Mar 25, 2026
similar, but the concrete constrain of mistral is a different one here it seems
ziouf commentedon Mar 25, 2026
I think it's related to this #16636 and so, to this #16638
github-actions commentedon Jul 5, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.