fix(codex): filter out prompt_cache_retention in OpenAI→Codex responses request conversion

Closes: #5068
This commit is contained in:
Luis Pater
2026-08-19 21:28:39 +08:00
parent ac0d1888c0
commit 2005788fc3
2 changed files with 27 additions and 1 deletions

View File

@@ -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)

View File

@@ -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(`{