-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[openai] Fix missing tool usage check (system message) #24768
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
base: main
Are you sure you want to change the base?
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.
Code Review
This pull request addresses a bug that prevented tool usage with gpt-oss
models. The issue was caused by the commentary
channel being incorrectly removed from the system message, which is necessary for tool call functionality. The fix involves passing a with_custom_tools
flag to the get_system_message
function, determined by whether tools are present in the request. This change correctly preserves the commentary
channel when tools are used. The fix is straightforward and effectively resolves the bug.
04938e5
to
ecafa3c
Compare
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.
Looks good to me, it would be great to add a unit test for this, there are some examples here the test likely doesn't even need the model to run, just that the messages are being generated properly here.
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.
A small nit would be that this will activate the commentary channel even if an empty list of tools is passed in, which is not uncommon. We could avoid that by using some like bool(request.tools)
instead of request.tools is not None
. But, I separately discovered this issue, Alec pointed me to this PR, and agree that this fix is needed to get accurate tool calling in Chat Completions with gpt-oss models.
Without this PR, I regularly see the models outputting non-built-in tool calls to the analysis channel, which isn't where they should go.
ecafa3c
to
f9043ac
Compare
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.
LGTM
9f989c4
to
38382b4
Compare
Fixed a bug where the commentary value was missing in Invalid Channel due to the absence of with_custom_tools value when fetching the system message. Signed-off-by: kyt <[email protected]>
f42b60e
to
33cc22e
Compare
This PR substantially improves Chat Completions streaming tool call handling for Harmony models, especially for gpt-oss-20b. Without this PR, the 20b model often (and 120b sometimes) outputs tool calls to the It may not reduce 100% of cases where tool calls inappropriately go to the |
@bbrowning |
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.
Hopefully this fixes. Thanks for this!
Just a note that the CI failures look unrelated, as both are failing in a disk space check on the docker build jobs. This PR doesn't change anything that would impact free disk space on the builder nodes. |
Purpose
Fixed a bug where the commentary value was missing in Invalid Channel due to the absence of with_custom_tools value when fetching the system message.