fix(codex-transform): preserve underscore when rewriting call_* tool-call ids#2499
Merged
Merged
Conversation
…call ids
`fixCallIDPrefix` builds malformed ids when the input has the standard
OpenAI `call_<nanoid>` prefix:
input: call_YYen1qxDejd2myJwcTCf7Nyp
output: fcYYen1qxDejd2myJwcTCf7Nyp ← no underscore between 'fc' and the nanoid
ChatGPT's codex backend then rejects the replayed item with:
400 Invalid 'input[N].id': 'fcYYen1qxDejd2myJwcTCf7Nyp'.
Expected an ID that contains letters, numbers, underscores, or
dashes, but this value contained additional characters.
Sub2api wraps that into 502 to the client. Clients using the OpenAI SDK
on the OAuth/codex path see every multi-hop turn (after the first tool
call) fail because the item_reference rewritten this way gets sent on
every subsequent hop.
The other two branches of the same function correctly emit `fc_`
(line 1029: pass-through when already `fc*`; line 1035 fallback:
`fc_" + id`). Only the `call_` → `fc_` rewrite was missing the
underscore — looks like a copy-paste slip during the original commit.
Fix: change `"fc"` to `"fc_"` on the call_ branch. One character.
Repro:
client (OpenAI SDK) sends a function_call_output whose call_id is
`call_<nanoid>` (default OpenAI format). The sub2api request body
also contains an item_reference whose id mirrors the call_id (also
`call_<nanoid>`). On the codex OAuth path, this rewrite fires for
the item_reference's id, producing the malformed value.
Affects: `platform=openai type=oauth` accounts whose clients use the
official OpenAI SDK / Responses API conventions (id prefix `call_`).
API-key accounts and bridge-mode requests are untouched.
Contributor
|
All contributors have signed the CLA. ✅ |
yetone
added a commit
to yetone/sub2api
that referenced
this pull request
May 15, 2026
pnpm 10+ promotes the 'Ignored build scripts' warning into an error
when the consumer hasn't approved scripts via package.json's
onlyBuiltDependencies. The frontend lockfile pulls esbuild@0.21.5 and
vue-demi@0.14.10, both of which need postinstall to materialize their
binaries, so a fresh `pnpm install` on v10/v11 dies with:
[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: esbuild@0.21.5,
vue-demi@0.14.10
exit code: 1
`pnpm@latest` resolves to whatever is current at build time, so the
Dockerfile builds non-deterministically — it works on v9 (the version
in use when the lockfile was first committed) and fails on v10+. Pin
to v9 so the image keeps building until upstream adopts approve-builds
or pre-declares onlyBuiltDependencies.
NOT a fix to the codex-transform bug — this is purely a build-side
deterministic-Dockerfile change. The fc-underscore PR (Wei-Shaw#2499) is the
real fix and lives on the upstream-bound branch.
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
Author
|
recheck |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
fixCallIDPrefixinopenai_codex_transform.gorewritescall_<nanoid>→fc<nanoid>(missing underscore). The codex backendthen rejects the malformed id with
400 Invalid 'input[N].id'andsub2api surfaces it as
502 Bad Gatewayto the client.Repro
Client uses the OpenAI SDK against an OAuth/codex-mode sub2api account.
The model emits a function_call with the standard
call_<nanoid>id;the client replays it on the next hop as an
item_referencewhose idmirrors the call_id.
fixCallIDPrefixthen produces e.g.fcYYen1qxDejd2myJwcTCf7Nyp(instead offc_YYen1qxDejd2myJwcTCf7Nyp),which the upstream codex /responses endpoint rejects:
Sub2api wraps that into
502 upstream request failed.Fix
One character — add the missing underscore on the
call_branch so itmatches the fallback branch directly below it.
Impact
platform=openai type=oauthaccounts whose clients usethe official OpenAI SDK / Responses-API id conventions
(
call_<nanoid>prefix). Every multi-hop turn after the first toolcall surfaces as 502 from sub2api.
applyCodexOAuthTransform) or clients that already emitfc_idsdirectly.
Test plan
function calls — previously 502 on hop 2+, expected 200 with fix.
call_-prefixedids (the fallback branch still handles them with
fc_prefix).