Repository navigation
fix(sse): accept Responses API custom tool_choice (#13122) - #13775
Merged
diegosouzapw merged 3 commits intoSep 16, 2026
Merged
diegosouzapw merged 3 commits into
diegosouzapw merged 3 commits into
Conversation
The Responses->Chat tool_choice translator in
open-sse/translator/request/openai-responses.ts handled type "function",
"local_shell", and "allowed_tools" but threw unsupported_feature for
anything else, including type "custom" — the shape Codex CLI's
wire_api="responses" sends to force a declared freeform/custom tool
(e.g. functions__exec). Custom tools are already normalized into a Chat
{input: string} function schema a few lines above (fixed under #1007),
so forcing that same declared name via Chat's tool_choice works once the
case is added, mirroring the existing local_shell branch.
Regression test: tests/unit/responses-custom-tool-choice-13122.test.ts
…2-responses-custom-tool-choice-rejected
…ce-rejected (base-red fix #13747)
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
diegosouzapw#13775) Merged in the 2026-09-16 sweep of the maintainer's own open PRs, at the owner's explicit instruction. No push was made to the PR branch: the merge took the head as the owning session left it (verified OPEN, non-draft and MERGEABLE against the release tip immediately before merging).
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.
Closes #13122
Root cause
open-sse/translator/request/openai-responses.tstranslates a Responses APItool_choiceobject in an
if/else ifchain. It handledtype: "function",type: "local_shell", andtype: "allowed_tools", but any other type — includingtype: "custom"— fell through to ageneric
unsupportedFeature()throw (400,unsupported_feature). Codex CLI'swire_api = "responses"sendstool_choice: {type: "custom", name: "..."}to force a call toa declared custom/freeform tool (e.g.
functions__exec), so every such request was rejected —even though the same request's
tools[].type === "custom"declaration is already accepted andnormalized into a Chat
{input: string}function schema a few lines above (fixed under #1007).The issue's other two complaints (custom tool calls coming back as
function_callwith JSONarguments instead of
custom_tool_callwith rawinput) are already fixed on this branch by#1007 and covered by
tests/unit/translator-openai-responses-custom-tool-1007.test.ts— nocode change was needed for those; they were a side effect of Reproduction 1's 400 in the
reporter's session.
Fix
Added a
tcType === "custom"branch, mirroring the existinglocal_shellcase: when theResponses
tool_choicehastype: "custom"and aname, translate it to Chat's{type: "function", function: {name}}, forcing the same declared custom tool by name. A{type: "custom"}choice with noname(not spec-compliant per the Responses API) still fallsthrough to the existing
unsupported_featurethrow.Regression test
tests/unit/responses-custom-tool-choice-13122.test.ts(new file, 3 tests):RED (unfixed code):
GREEN (fixed code):
Gates run
DATA_DIR=$(mktemp -d) node --import tsx/esm --test --test-force-exit tests/unit/responses-custom-tool-choice-13122.test.ts→ 3/3 passDATA_DIR=$(mktemp -d) node --import tsx/esm --test --test-force-exit tests/unit/translator-openai-responses-custom-tool-1007.test.ts tests/unit/responses-chat-translation-gaps.test.ts tests/unit/responses-additional-tools.test.ts→ 31/31 pass (existing coverage of the same translator, unaffected)npx eslint --suppressions-location config/quality/eslint-suppressions.json open-sse/translator/request/openai-responses.ts tests/unit/responses-custom-tool-choice-13122.test.ts→ clean, exit 0npm run check:open-sse-typecheck→ clean, exit 0node scripts/check/check-file-size.mjs→ no violation on touched files (1 pre-existing violation onopen-sse/utils/stream.ts, untouched by this PR — base drift)node scripts/check/check-complexity.mjs→ OKnode scripts/check/check-cognitive-complexity.mjs→ OKnode scripts/check/check-test-discovery.mjs→ OK, new test file discoveredExisting tests aligned
None — no existing assertion encoded the old buggy
custom→ throw contract; the new branch ispurely additive and all 31 tests in the touched files' existing suites pass unmodified.