From 2005788fc39681a846feb84006cbb76b7bd1b68f Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Wed, 19 Aug 2026 21:28:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(codex):=20filter=20out=20`prompt=5Fcache=5F?= =?UTF-8?q?retention`=20in=20OpenAI=E2=86=92Codex=20responses=20request=20?= =?UTF-8?q?conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #5068 --- .../codex_openai-responses_request.go | 2 +- .../codex_openai-responses_request_test.go | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) 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 6a759b3f0..ea617c23c 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_request.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_request.go @@ -31,7 +31,7 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte, rawJSON = deleteCodexRequestFields(rawJSON, "service_tier") } - rawJSON = deleteCodexRequestFields(rawJSON, "truncation", "prompt_cache_options") + rawJSON = deleteCodexRequestFields(rawJSON, "truncation", "prompt_cache_options", "prompt_cache_retention") rawJSON = stripCodexResponsesCacheBreakpoints(rawJSON) rawJSON = applyResponsesCompactionCompatibility(rawJSON) diff --git a/internal/translator/codex/openai/responses/codex_openai-responses_request_test.go b/internal/translator/codex/openai/responses/codex_openai-responses_request_test.go index 493f288bd..60efdd290 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_request_test.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_request_test.go @@ -253,6 +253,7 @@ func TestConvertOpenAIResponsesRequestToCodexNormalizesRequiredFields(t *testing "service_tier":"standard", "truncation":"auto", "prompt_cache_options":{"mode":"implicit"}, + "prompt_cache_retention":"24h", "user":"request-owner", "input":[{"type":"message","role":"system","content":"hello"}] }`) @@ -283,6 +284,7 @@ func TestConvertOpenAIResponsesRequestToCodexNormalizesRequiredFields(t *testing "service_tier", "truncation", "prompt_cache_options", + "prompt_cache_retention", "user", } { if gjson.GetBytes(output, path).Exists() { @@ -291,6 +293,30 @@ func TestConvertOpenAIResponsesRequestToCodexNormalizesRequiredFields(t *testing } } +func TestConvertOpenAIResponsesRequestToCodex_FiltersPromptCacheRetention(t *testing.T) { + inputJSON := []byte(`{ + "model": "gpt-5.6-terra", + "prompt_cache_retention": "24h", + "input": [ + { + "type": "message", + "role": "user", + "content": [ + { + "type": "input_text", + "text": "hello" + } + ] + } + ] + }`) + + output := ConvertOpenAIResponsesRequestToCodex("gpt-5.6-terra", inputJSON, true) + if gjson.GetBytes(output, "prompt_cache_retention").Exists() { + t.Fatalf("prompt_cache_retention should be removed: %s", string(output)) + } +} + // TestConvertSystemRoleToDeveloper_AssistantRole tests that assistant role is preserved func TestConvertSystemRoleToDeveloper_AssistantRole(t *testing.T) { inputJSON := []byte(`{