From 9e3b84939ffb1d46a9ef7f9f9a86723714702fab Mon Sep 17 00:00:00 2001 From: Ben Vargas Date: Sat, 27 Sep 2025 15:44:33 -0600 Subject: [PATCH] fix(translator): remove unsupported token limit fields for Codex Responses API The OpenAI Codex Responses API (chatgpt.com/backend-api/codex/responses) rejects requests containing max_output_tokens and max_completion_tokens fields, causing Factory CLI to fail with "Unsupported parameter" errors. This fix strips these incompatible fields during request translation, allowing Factory CLI to work properly with CLIProxyAPI when using ChatGPT Plus/Pro OAuth. Fixes compatibility issue where Factory sends token limit parameters that aren't supported by the Codex Responses endpoint. --- .../codex/openai/responses/codex_openai-responses_request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/translator/codex/openai/responses/codex_openai-responses_request.go b/internal/translator/codex/openai/responses/codex_openai-responses_request.go index 3c868682..d9b3b722 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_request.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_request.go @@ -17,6 +17,9 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte, rawJSON, _ = sjson.SetBytes(rawJSON, "store", false) rawJSON, _ = sjson.SetBytes(rawJSON, "parallel_tool_calls", true) rawJSON, _ = sjson.SetBytes(rawJSON, "include", []string{"reasoning.encrypted_content"}) + // Codex Responses rejects token limit fields, so strip them out before forwarding. + rawJSON, _ = sjson.DeleteBytes(rawJSON, "max_output_tokens") + rawJSON, _ = sjson.DeleteBytes(rawJSON, "max_completion_tokens") rawJSON, _ = sjson.DeleteBytes(rawJSON, "temperature") rawJSON, _ = sjson.DeleteBytes(rawJSON, "top_p")