Skip to content

Conversation

@CormickKneey
Copy link
Collaborator

Description

This PR enhances the OpenAI Agents SDK integration in AReaL by adding proper tool output format conversion and improving parameter handling. The changes ensure compatibility with the OpenAI chat template format and fix parameter validation issues.

Key improvements:

  • Added _convert_tool_output_format() function to convert custom tool output format:
{"call_id": "call_b072608844e54c8ea88379cb", "output": "root@3f3f8caec37b:/app# ls -l process_data.sh\n-rw-r--r-- 1 root root 49 Oct 15 09:38 process_data.sh\nroot@3f3f8caec37b:/app#\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",  "type": "function_call_output"}
  • Enhanced message building logic to automatically convert tool outputs when processing conversation history
  • Improved parameter validation with is_omitted() helper function to properly handle NOT_GIVEN and Omit types from the OpenAI SDK
  • Fixed metadata and tool choice parameter handling in both completions and responses APIs

Related Issue

Fixes # (issue number - please update if there's a specific issue)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

No breaking changes - this is a backward-compatible enhancement that improves tool output handling.

Additional Context

  • The is_omitted() helper function provides a more robust way to handle the various "not provided" parameter types from the OpenAI SDK, preventing potential validation errors.
  • I have successfully trained the model several times using this fix. Tracking at example pr

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @CormickKneey, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the OpenAI Agents SDK integration by refining how tool outputs are processed and how various parameters are validated. The changes ensure that custom tool outputs are correctly converted to the standard OpenAI chat template and that parameters like metadata and tool_choice are handled robustly, improving overall compatibility and reliability of the SDK.

Highlights

  • Tool Output Format Conversion: Introduced a new internal function, _convert_tool_output_format(), to standardize custom tool output formats into the OpenAI chat template format. This ensures compatibility when processing conversation history.
  • Improved Parameter Validation: Added a robust is_omitted() helper function to correctly identify and handle NOT_GIVEN and Omit types from the OpenAI SDK, preventing validation errors and ensuring proper default behavior.
  • Enhanced Metadata and Tool Choice Handling: Refactored the handling of metadata and tool_choice parameters in both completions and responses APIs, leveraging the new is_omitted() function for more consistent and accurate parameter processing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 enhances the OpenAI Agents SDK integration by introducing helper functions to handle tool output conversion and parameter validation. The new _convert_tool_output_format function correctly transforms custom tool outputs, and the is_omitted function provides a centralized way to check for omitted parameters, improving code clarity and robustness. My review includes a couple of suggestions to further improve the reliability of these new helper functions.

@CormickKneey CormickKneey force-pushed the fix_openai_agent_tools branch from 9760151 to 9e4d99a Compare October 31, 2025 05:09
Copy link
Collaborator

@dhh1995 dhh1995 left a comment

Choose a reason for hiding this comment

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

Others LGTM

@CormickKneey CormickKneey force-pushed the fix_openai_agent_tools branch from 1635700 to 4665b69 Compare October 31, 2025 14:40
@CormickKneey
Copy link
Collaborator Author

Happy Monday, folks! Could you please help review this PR when you have a moment?
@fishcrap @dhh1995

Copy link
Collaborator

@fishcrap fishcrap left a comment

Choose a reason for hiding this comment

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

LGTM!

@fishcrap fishcrap merged commit 22a4896 into inclusionAI:main Nov 3, 2025
1 check passed
daihaowz pushed a commit that referenced this pull request Nov 27, 2025
Bruce-rl-hw pushed a commit to Bruce-rl-hw/AReaL-vllm that referenced this pull request Dec 4, 2025
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