Skip to content

Conversation

@XInTheDark
Copy link

Problem

  • OpenAI Chat Completions requests that include built-in tools like {"type":"web_search"} were dropped when translating to the Responses API (Codex), resulting in upstream receiving tools:[] and no web search.

Fix

  • Pass through non-function tool entries unchanged during OpenAI Chat Completions -> Codex (Responses) translation.
  • Preserve tool_choice for built-in tools (and flatten function tool_choice to Responses shape).
  • Also preserve built-in tools when converting OpenAI Responses -> OpenAI Chat Completions.

Tests

  • go test ./...
  • Added test/builtin_tools_translation_test.go

- Pass through non-function tool definitions like web_search

- Translate tool_choice for built-in tools and function tools

- Add regression tests for built-in tool passthrough
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @XInTheDark, 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 resolves a critical issue where built-in tools, such as "web_search", were inadvertently discarded during the translation process between OpenAI Chat Completions and the Responses API. The changes ensure that these tools, along with their associated "tool_choice" settings, are accurately preserved in both translation directions. Additionally, a new "copilot-unlimited-mode" configuration has been introduced to enhance compatibility with "copilot-api" by automatically prepending an assistant message to relevant requests, which may help in managing API rate limits.

Highlights

  • Tool Preservation: Ensures built-in tools (e.g., "web_search") are no longer dropped during translation from OpenAI Chat Completions to the Responses API (Codex).
  • Tool Choice Handling: Correctly preserves "tool_choice" for built-in tools and flattens function "tool_choice" into the Responses API format.
  • Bidirectional Tool Support: Extends tool preservation to also cover the translation from OpenAI Responses back to OpenAI Chat Completions.
  • Copilot Unlimited Mode: Introduces a new configuration option ("copilot-unlimited-mode") to prepend a default assistant message to "/v1/chat/completions" requests, aiming to improve compatibility and potentially avoid rate limiting with "copilot-api".
  • New Tests: Adds dedicated tests ("builtin_tools_translation_test.go" and "openai_handlers_test.go") to validate the correct translation and preservation of built-in tools and the functionality of the new "copilot-unlimited-mode".
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.

@XInTheDark XInTheDark closed this Dec 15, 2025
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 correctly implements the fix to preserve built-in tools like web_search during translation between OpenAI and Codex API formats. The changes in the translator files are logical and are well-covered by the new tests.

However, this PR also introduces a new copilot-unlimited-mode feature and includes some refactoring in the amp module. These changes are not mentioned in the PR description, making the review process more difficult. In the future, it would be beneficial to keep pull requests focused on a single concern to improve clarity and reviewability.

Overall, the changes are positive, but the scope of the PR could be improved.

Comment on lines +102 to +104
if err != nil {
return rawJSON
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The error from sjson.SetRawBytes is silently ignored. While an error here is unlikely, it's good practice to log it for debugging purposes. This would help identify potential issues if the input rawJSON is malformed in an unexpected way.

You will need to import log "github.com/sirupsen/logrus" to apply this suggestion, which appears to be the standard logger for this project.

Suggested change
if err != nil {
return rawJSON
}
if err != nil {
log.Warnf("Failed to prepend assistant message for copilot unlimited mode: %v", err)
return rawJSON
}

@XInTheDark
Copy link
Author

Superseded by #553 (same fix, rebased onto upstream main; single-commit PR).

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.

1 participant