Repository navigation
fix(proxy): send a forced tool_choice in the Responses shape - #212
Merged
GoDiao merged 2 commits intoOct 30, 2026
Merged
Conversation
anthropicToOpenaiResponses reused the Chat Completions form
{type:'function', function:{name}} for tool_choice type=tool. The Responses API
takes the flat {type:'function', name}, so a forced tool from an Anthropic client
was rejected with a 400.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
GoDiao
approved these changes
Oct 30, 2026
GoDiao
left a comment
Owner
There was a problem hiding this comment.
Thanks @pcbeingused333, nice find! We checked it against OpenRouter's Responses API with one request that differs only in tool_choice: the nested { type: 'function', function: { name } } that main sent gets a 400 (invalid_prompt), and the flat { type: 'function', name } from this PR succeeds and the model calls the tool.
We pushed a merge of main to resolve the CHANGELOG conflict. Your entry had landed in the 0.6.1 section, so we moved it under [Unreleased] and added a thanks line. Approving and merging. Thanks again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a client sends an Anthropic request with a forced tool (
tool_choice: { type: 'tool', name }) through a provider that uses the OpenAI Responses API,anthropicToOpenaiResponsesconverted it with the Chat Completions form,{ type: 'function', function: { name } }. The Responses API takes the flat form{ type: 'function', name }, so the upstream rejected the request with a 400.The Responses converter now returns
{ type: 'function', name };any,autoandnonekeep mapping torequired,autoandnone, and the Chat Completions converter is unchanged (its nested form is the correct one there).The flat shape matches what this repo already assumes elsewhere for the same API:
OpenAIResponsesRequest.toolsintransform/types.tscarries{ type: 'function', name, description, parameters }, with the name at the top level, whileOpenAIToolfor Chat Completions keeps it underfunction.Tests in
proxy-transform.test.ts: the forced-tool shape (fails on the previous code) and the three string mappings.bun test src/server/__tests__/proxy-transform.test.ts: 42 pass. Not run against a live Responses upstream. CHANGELOG line under Unreleased.This change was made with Claude Code.