fix(openai): preserve current Codex compact payload fields
This commit is contained in:
@@ -4864,7 +4864,18 @@ func normalizeOpenAICompactRequestBody(body []byte) ([]byte, bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
normalized := []byte(`{}`)
|
normalized := []byte(`{}`)
|
||||||
for _, field := range []string{"model", "input", "instructions", "previous_response_id"} {
|
// Keep the current Codex /compact schema while still dropping request-scoped
|
||||||
|
// fields such as prompt_cache_key, store, and stream.
|
||||||
|
for _, field := range []string{
|
||||||
|
"model",
|
||||||
|
"input",
|
||||||
|
"instructions",
|
||||||
|
"tools",
|
||||||
|
"parallel_tool_calls",
|
||||||
|
"reasoning",
|
||||||
|
"text",
|
||||||
|
"previous_response_id",
|
||||||
|
} {
|
||||||
value := gjson.GetBytes(body, field)
|
value := gjson.GetBytes(body, field)
|
||||||
if !value.Exists() {
|
if !value.Exists() {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1767,6 +1767,24 @@ func TestOpenAIResponsesRequestPathSuffix(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNormalizeOpenAICompactRequestBodyPreservesCurrentCodexPayloadFields(t *testing.T) {
|
||||||
|
body := []byte(`{"model":"gpt-5.5","input":[{"type":"message","role":"user","content":"compact me"}],"instructions":"compact-test","tools":[{"type":"function","name":"shell"}],"parallel_tool_calls":true,"reasoning":{"effort":"high"},"text":{"verbosity":"low"},"previous_response_id":"resp_123","store":true,"stream":true,"prompt_cache_key":"cache_123"}`)
|
||||||
|
|
||||||
|
normalized, changed, err := normalizeOpenAICompactRequestBody(body)
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, changed)
|
||||||
|
require.Equal(t, "gpt-5.5", gjson.GetBytes(normalized, "model").String())
|
||||||
|
require.True(t, gjson.GetBytes(normalized, "tools").Exists())
|
||||||
|
require.True(t, gjson.GetBytes(normalized, "parallel_tool_calls").Bool())
|
||||||
|
require.Equal(t, "high", gjson.GetBytes(normalized, "reasoning.effort").String())
|
||||||
|
require.Equal(t, "low", gjson.GetBytes(normalized, "text.verbosity").String())
|
||||||
|
require.Equal(t, "resp_123", gjson.GetBytes(normalized, "previous_response_id").String())
|
||||||
|
require.False(t, gjson.GetBytes(normalized, "store").Exists())
|
||||||
|
require.False(t, gjson.GetBytes(normalized, "stream").Exists())
|
||||||
|
require.False(t, gjson.GetBytes(normalized, "prompt_cache_key").Exists())
|
||||||
|
}
|
||||||
|
|
||||||
func TestOpenAIBuildUpstreamRequestOpenAIPassthroughPreservesCompactPath(t *testing.T) {
|
func TestOpenAIBuildUpstreamRequestOpenAIPassthroughPreservesCompactPath(t *testing.T) {
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
|
|||||||
Reference in New Issue
Block a user