fix(codex): preserve custom tools during request normalization

Add CODEX_PASSTHROUGH_TOOL_TYPES allowlist so Responses-native freeform
tools (e.g. grammar-backed apply_patch) survive normalizeCodexTools and
reach the upstream Codex Responses API intact.

Refs #1907

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Sutarto Jordan Chrisfivo
2026-06-21 16:01:45 +07:00
committed by decolua
co-authored by Cursor
parent 13abe7f7f6
commit ed68bcedf8
2 changed files with 103 additions and 0 deletions
+4
View File
@@ -26,6 +26,9 @@ const CODEX_HOSTED_TOOL_TYPES = new Set([
"tool_search"
]);
// Responses-native freeform tools carry a name plus format payload and must pass through intact.
const CODEX_PASSTHROUGH_TOOL_TYPES = new Set(["custom"]);
// Allowlist of fields accepted by Codex Responses API — anything else is stripped
const RESPONSES_API_ALLOWLIST = new Set([
"model", "input", "instructions", "tools", "tool_choice", "stream", "store",
@@ -72,6 +75,7 @@ function normalizeCodexTools(body) {
return true;
}
if (type !== "function") {
if (CODEX_PASSTHROUGH_TOOL_TYPES.has(type)) return true;
if (!type || tool.function || typeof tool.name === "string") return false;
return CODEX_HOSTED_TOOL_TYPES.has(type);
}