mistral generator workaround for magistral models. openai-style gener… #1526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ator bugfix for certain types of None responses.
This has two fixes: the first for mistral and the second (very minor) one for OpenAI-style generators.
The first fix works around a bug in the
mistralaipackage which doesn't account for thinking tokens in Magistral models. If the response fails the pydantic validation inmistralai, we will fall back to using raw HTTP requests.We can get rid of the HTTP workaround once mistral fixes that bug.
Possibly related bug: mistralai/client-python#252
The second, OpenAI fix is a minor one that handles certain
Noneresponses better so that the run doesn't just fail. I encountered suchNoneresponses occasionally while queryinggemini-2.5.flash.Verification
Try to start a run on
magistral-medium-2509with the previous version of the generator. It doesn't really matter which probe. At some point it will fail with a Pydantic validation error, because the structure of the response doesn't fitmistralai's pydantic model.With this version of the generator, the Pydantic validation error will be written to the log, but garak will retry with a raw HTTP request and the run will continue.