Skip to content

Commit 348a487

Browse files
committed
fix(codex-transform): preserve underscore when rewriting call_* tool-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.
1 parent 6e66edb commit 348a487

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

backend/internal/service/openai_codex_transform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ func filterCodexInputWithOptions(input []any, opts codexInputFilterOptions) []an
10301030
return id
10311031
}
10321032
if strings.HasPrefix(id, "call_") {
1033-
return "fc" + strings.TrimPrefix(id, "call_")
1033+
return "fc_" + strings.TrimPrefix(id, "call_")
10341034
}
10351035
return "fc_" + id
10361036
}

0 commit comments

Comments
 (0)