bugfix: improve qwen25 tool-call parsing robustness.#1010
bugfix: improve qwen25 tool-call parsing robustness.#1010yingxudeng wants to merge 1 commit intojd-opensource:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves the robustness of tool-call parsing for the qwen25 format by using a partial JSON parser to handle malformed payloads. The changes are well-supported by new regression tests. My review identifies one critical issue in the exception handling logic within xllm/api_service/utils.h. An unhandled exception during parsing can lead to silent data loss, as the original input text is discarded. I've provided feedback on how to make the error handling more robust to prevent this.
| if (call_info_list.empty()) { | ||
| result.text = std::move(text); | ||
| result.finish_reason = std::move(finish_reason); | ||
| return result; | ||
| } |
There was a problem hiding this comment.
This block correctly handles the case where parse_non_stream returns no tool calls, which is a good improvement for robustness. However, there is a more critical robustness issue within the surrounding try...catch block that should also be addressed.
If parser.parse_non_stream or any subsequent operation throws an exception, the catch block at line 137 only logs the error. The function then returns a default-constructed ToolCallResult, which means the original text is lost. This is a form of silent data loss.
To fully improve robustness, the catch block should be modified to fall back gracefully by returning the original text and finish_reason, similar to how this new block handles parsing failures. This would prevent data loss in case of unexpected exceptions.
ef6477f to
25cd973
Compare
No description provided.