From 348a487739cf5d0b7e4b44f76003a38adba7a89c Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 15 May 2026 23:29:56 +0800 Subject: [PATCH] fix(codex-transform): preserve underscore when rewriting call_* tool-call ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `fixCallIDPrefix` builds malformed ids when the input has the standard OpenAI `call_` 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_` (default OpenAI format). The sub2api request body also contains an item_reference whose id mirrors the call_id (also `call_`). 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. --- backend/internal/service/openai_codex_transform.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/service/openai_codex_transform.go b/backend/internal/service/openai_codex_transform.go index a3b69dee..5b5f2bc3 100644 --- a/backend/internal/service/openai_codex_transform.go +++ b/backend/internal/service/openai_codex_transform.go @@ -1030,7 +1030,7 @@ func filterCodexInputWithOptions(input []any, opts codexInputFilterOptions) []an return id } if strings.HasPrefix(id, "call_") { - return "fc" + strings.TrimPrefix(id, "call_") + return "fc_" + strings.TrimPrefix(id, "call_") } return "fc_" + id }