fix(codex): remove unsupported 'user' field from /v1/responses payload
Unified · Split
| @@ -27,6 +27,9 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte, · 26 unmodified lines | ||
| 27 | 27 | rawJSON, _ = sjson.DeleteBytes(rawJSON, "top_p") |
| 28 | 28 | rawJSON, _ = sjson.DeleteBytes(rawJSON, "service_tier") |
| 29 | 29 | |
| 30 | + // Delete the user field as it is not supported by the Codex upstream. | |
| 31 | + rawJSON, _ = sjson.DeleteBytes(rawJSON, "user") | |
| 32 | + | |
| 30 | 33 | // Convert role "system" to "developer" in input array to comply with Codex API requirements. |
| 31 | 34 | rawJSON = convertSystemRoleToDeveloper(rawJSON) |
| 32 | 35 | |
| @@ -263,3 +263,20 @@ func TestConvertSystemRoleToDeveloper_AssistantRole(t *testing.T) { · 262 unmodified lines | ||
| 263 | 263 | t.Errorf("Expected third role 'assistant', got '%s'", thirdRole.String()) |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | + | |
| 267 | +func TestUserFieldDeletion(t *testing.T) { | |
| 268 | + inputJSON := []byte(`{ | |
| 269 | + "model": "gpt-5.2", | |
| 270 | + "user": "test-user", | |
| 271 | + "input": [{"role": "user", "content": "Hello"}] | |
| 272 | + }`) | |
| 273 | + | |
| 274 | + output := ConvertOpenAIResponsesRequestToCodex("gpt-5.2", inputJSON, false) | |
| 275 | + outputStr := string(output) | |
| 276 | + | |
| 277 | + // Verify user field is deleted | |
| 278 | + userField := gjson.Get(outputStr, "user") | |
| 279 | + if userField.Exists() { | |
| 280 | + t.Errorf("user field should be deleted, but it was found with value: %s", userField.Raw) | |
| 281 | + } | |
| 282 | +} | |