Skip to content

Conversation

levunet
Copy link

@levunet levunet commented Sep 12, 2025

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.

image

Copy link
Contributor

@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 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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Collaborator

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation bot moved this from To Triage to Ready in gpt-oss Issues & Enhancements Sep 16, 2025
@chaunceyjiang chaunceyjiang added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 16, 2025
@levunet levunet force-pushed the feat/fix_tool_check branch from 9f989c4 to 38382b4 Compare September 16, 2025 13:36
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]>
@bbrowning
Copy link
Contributor

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 analysis channel, which is wrong. We could adjust our streaming parser code to handle that, which is a fairly trivial change. However, the more appropriate fix is this PR, which activates the commentary channel when the request contains tools.

It may not reduce 100% of cases where tool calls inappropriately go to the analysis channel, but it makes a massive improvement.

@levunet
Copy link
Author

levunet commented Sep 26, 2025

@bbrowning
There are additional PRs that have modified the content you mentioned. I believe the harmony library improvements have resolved the issue close to 100%. If you need it, I recommend using that harmony code.

#24954
openai/harmony#76

Copy link
Collaborator

@aarnphm aarnphm left a 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!

@bbrowning
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend gpt-oss Related to GPT-OSS models ready ONLY add when PR is ready to merge/full CI is needed
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

5 participants