Skip to content

Add GPT-OSS tool calling support#5464

Merged
qgallouedec merged 26 commits intomainfrom
gpt-oss-tool-calling
Apr 9, 2026
Merged

Add GPT-OSS tool calling support#5464
qgallouedec merged 26 commits intomainfrom
gpt-oss-tool-calling

Conversation

@qgallouedec
Copy link
Copy Markdown
Member

@qgallouedec qgallouedec commented Apr 6, 2026

  • Add response schema for GPT-OSS (done by Claude)
  • Add gptoss.jinja template for identity matching in add_response_schema
  • Add GPT-OSS to TestAddResponseSchema and TestParseResponse test parametrizations
  • Add GPT-OSS to supported models in agent training docs

Part of #5460

Warning

Requires/contains #5459


Note

Medium Risk
Introduces a new GPT-OSS response parsing schema and updates GRPO tool-suffix tokenization to depend on real tool names, which could affect tool-call loop formatting and parsing across models if templates behave differently.

Overview
Adds GPT-OSS tool-calling support by introducing a new gptoss.jinja identity template and a corresponding gptoss_schema, and wiring both into add_response_schema so parse_response can extract content and single tool calls from GPT-OSS outputs.

Updates GRPO tool-call suffix extraction in both GRPOTrainer and AsyncRolloutWorker to build the dummy conversation using the actual tool name (not "dummy"), matching templates (like GPT-OSS) that derive tool-response headers from the preceding tool call.

Extends response-schema/parsing tests to include a tiny-GptOssForCausalLM tokenizer with model-specific skips/expectations, and documents GPT-OSS as a supported agent-training model in grpo_trainer.md.

Reviewed by Cursor Bugbot for commit 392dece. Bugbot is set up for automated code reviews on this repo. Configure here.

@qgallouedec qgallouedec changed the title Gpt oss tool calling Add GPT-OSS tool calling support Apr 6, 2026
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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.

Reviewed commit: b18e39efd6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@qgallouedec
Copy link
Copy Markdown
Member Author

cc @Rocketknight1 for the schema

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 450b9ef. Configure here.

"""
if tokenizer.chat_template == gptoss_chat_template:
tokenizer.response_schema = gptoss_schema
return tokenizer
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefix-preserving check diverges from suffix extraction construction

Low Severity

is_chat_template_prefix_preserving still uses a hardcoded "dummy" tool name, while _get_tool_suffix_ids was changed to use the real tool name via tool_messages[0]["name"]. The comment on line 350 explicitly states "Use the same dummy messages as _get_tool_suffix_ids", but the constructions now differ. For GPT-OSS, the tool name is embedded in the rendered text (e.g. to=functions.NAME), so the validation function is no longer testing the exact property that _get_tool_suffix_ids relies on.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 450b9ef. Configure here.

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
@qgallouedec qgallouedec merged commit 720c1f2 into main Apr 9, 2026
16 checks passed
@qgallouedec qgallouedec deleted the gpt-oss-tool-calling branch April 9, 2026 01:46
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.

3 participants