Fixing MiniCPM5 and Mistral bfcl errors - #4479
Open
przepeck wants to merge 7 commits into
Open
Conversation
przepeck
requested review from
mzegla and
pgladkows
and
a lite review from Copilot
August 26, 2026 06:09
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness of OVMS LLM streaming by preventing tool/output-parser exceptions from unwinding GenAI’s internal generate() loop (which can leave the underlying InferRequest “busy”), and adds regression tests for Mistral and MiniCPM5 parser edge cases.
Changes:
- Catch output-parser exceptions inside
OVMSTextStreamerflush and cancel generation gracefully while recording a parser-error flag. - Propagate parser failure to legacy executors by checking
OVMSTextStreamer::hadParserError()aftergenerate(). - Add tests for Mistral streaming tool-call ordering and MiniCPM5 unterminated reasoning blocks; harden MiniCPM5 reasoning token stripping for missing end token.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/llm/output_parsers/mistral_output_parser_test.cpp | Adds a regression test for a streaming tool-call JSON shape where arguments appears before name. |
| src/test/llm/output_parsers/minicpm5_output_parser_test.cpp | Adds a regression test ensuring unterminated <think>/reasoning does not crash and still yields tool calls. |
| src/test/http_openai_handler_test.cpp | Adds an integration-style test verifying parser exception cancels streaming and leads to request failure. |
| src/llm/visual_language_model/legacy/legacy_executor.cpp | Marks generation as failed when the text streamer reports a parser error. |
| src/llm/ovms_text_streamer.hpp | Exposes hadParserError() to let callers detect parser failures after generation returns. |
| src/llm/ovms_text_streamer.cpp | Wraps parseChunk() in try/catch; cancels generation and emits a final callback on parser errors. |
| src/llm/omni_model/legacy/legacy_executor.cpp | Marks generation as failed when the text streamer reports a parser error. |
| src/llm/language_model/legacy/legacy_executor.cpp | Marks generation as failed when the text streamer reports a parser error. |
| src/llm/io_processing/minicpm5/minicpm5_tool_parser.cpp | Avoids UB/crash when the reasoning end token is missing by keeping tokens unchanged. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🛠 Summary
CVS-192979
Hanlding exceptions thrown in tool parsers, fixing Mistrals.
Temporary fix for MiniCPM5 util servable refactor is introduced
🧪 Checklist
``