fix(claude): honor disable_parallel_tool_use#2187
fix(claude): honor disable_parallel_tool_use#2187luispater merged 2 commits intorouter-for-me:devfrom
Conversation
Summary of ChangesHello, 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 enhances the Claude-to-Codex request translation mechanism by correctly interpreting the disable_parallel_tool_use flag. This ensures that clients unable to process multiple tool calls in a single response are accommodated, preventing potential compatibility issues and improving the robustness of the API integration. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the Claude-to-Codex request translator to honor the disable_parallel_tool_use flag sent by Claude-compatible clients, instead of always hardcoding parallel_tool_calls=true.
Changes:
- Read
disable_parallel_tool_usefrom the incoming Claude request and invert it to setparallel_tool_callsaccordingly, defaulting totruewhen absent. - Add tests covering the three cases: flag absent, flag
true, and flagfalse.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/translator/codex/claude/codex_claude_request.go |
Replace hardcoded parallel_tool_calls=true with logic that respects disable_parallel_tool_use |
internal/translator/codex/claude/codex_claude_request_test.go |
Add table-driven tests for the three disable_parallel_tool_use scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request correctly implements support for Claude's disable_parallel_tool_use flag, defaulting to parallel tool calls unless explicitly disabled. The accompanying tests cover the necessary cases. I have one suggestion to make the implementation more concise by leveraging the behavior of the gjson library.
| parallelToolCalls := true | ||
| if disableParallelToolUse := rootResult.Get("disable_parallel_tool_use"); disableParallelToolUse.Exists() { | ||
| parallelToolCalls = !disableParallelToolUse.Bool() | ||
| } |
There was a problem hiding this comment.
This logic can be made more concise. The gjson.Result.Bool() method returns false for non-existent keys or any value that is not boolean true. You can leverage this to simplify these four lines into a single line.
| parallelToolCalls := true | |
| if disableParallelToolUse := rootResult.Get("disable_parallel_tool_use"); disableParallelToolUse.Exists() { | |
| parallelToolCalls = !disableParallelToolUse.Bool() | |
| } | |
| parallelToolCalls := !rootResult.Get("disable_parallel_tool_use").Bool() |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19e1a4447a
ℹ️ 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".
| if disableParallelToolUse := rootResult.Get("disable_parallel_tool_use"); disableParallelToolUse.Exists() { | ||
| parallelToolCalls = !disableParallelToolUse.Bool() |
There was a problem hiding this comment.
Read disable_parallel_tool_use from tool_choice
The new lookup reads disable_parallel_tool_use from the top level of the request, but Claude tool-selection options are carried in tool_choice (the repo’s Claude translators consistently parse tool_choice.*, e.g. internal/translator/gemini/claude/gemini_claude_request.go). In requests that set tool_choice.disable_parallel_tool_use=true, this code path is skipped and parallel_tool_calls remains true, so clients that explicitly opt out of parallel tool invocations will still receive parallel tool-use responses.
Useful? React with 👍 / 👎.
…ble-parallel-tool-calls fix(claude): honor disable_parallel_tool_use
Summary
disable_parallel_tool_useflag when setting Codexparallel_tool_callsparallel_tool_callstotrueonly when the client does not send a valueWhy
Some Claude-compatible clients set
disable_parallel_tool_usebecause they cannot handle a single assistant turn that emits multipletool_useblocks. If we always forceparallel_tool_calls=true, we ignore that capability signal and may return a batched tool-calling response those clients cannot consume.