-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[Frontend][2/n] remove empty content from _parse_tool_calls_from_content #28331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if content.strip() == "": | ||
| content = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard None before trimming parsed content
When extract_tool_calls() returns content=None (e.g., OpenAIToolParser leaves final_content unset when a model emits only tool calls), the new content.strip() call will raise AttributeError and abort the request. Previously this branch safely returned (function_calls, None); now any tool-only response will crash automatic tool parsing instead of succeeding. A simple if content and content.strip() == "": ... avoids the regression.
Useful? React with 👍 / 👎.
| for tool_call in tool_call_info.tool_calls | ||
| ) | ||
| content = tool_call_info.content | ||
| if content.strip() == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we remove whitespace characters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaunceyjiang if we keep it, we get an extra output item like this, which is pointless to show for the user
{
"id": "msg_33be381a036e49e8abc0faead1e05752",
"content": [
{
"annotations": [],
"text": "\n\n",
"type": "output_text",
"logprobs": null
}
],
"role": "assistant",
"status": "completed",
"type": "message"
},
Signed-off-by: Andrew Xia <axia@fb.com>
Head branch was pushed to by a user without write access
1e3de73 to
0e90d57
Compare
…ent (vllm-project#28331) Signed-off-by: Andrew Xia <axia@fb.com> Co-authored-by: Andrew Xia <axia@fb.com> Signed-off-by: xuebwang-amd <xuebwang@amd.com>
…ent (vllm-project#28331) Signed-off-by: Andrew Xia <axia@fb.com> Co-authored-by: Andrew Xia <axia@fb.com>
Purpose
I noticed that our tool parser often times may leave whitespace after the tool call, which gets outputted to the user. We should strip it out.
Test Plan
qwen3 example:
client
Test Result