Skip to content

bugfix: improve qwen25 tool-call parsing robustness.#1010

Open
yingxudeng wants to merge 1 commit intojd-opensource:mainfrom
yingxudeng:bugfix/qwen25_tool_call_0306
Open

bugfix: improve qwen25 tool-call parsing robustness.#1010
yingxudeng wants to merge 1 commit intojd-opensource:mainfrom
yingxudeng:bugfix/qwen25_tool_call_0306

Conversation

@yingxudeng
Copy link
Collaborator

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +105 to +109
if (call_info_list.empty()) {
result.text = std::move(text);
result.finish_reason = std::move(finish_reason);
return result;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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.

DongheJin
DongheJin previously approved these changes Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants