From c0fbc1979e44c9eef1816fd80c425f75afe9b86a Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Fri, 19 Sep 2025 09:19:18 +0800 Subject: [PATCH] refactor: remove redundant Codex instruction validation logic - Eliminated unnecessary calls to `misc.CodexInstructions` and corresponding checks in response processing. - Streamlined instruction handling by directly updating "instructions" field from the original request payload. --- .../responses/codex_openai-responses_response.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/internal/translator/codex/openai/responses/codex_openai-responses_response.go b/internal/translator/codex/openai/responses/codex_openai-responses_response.go index 6619e180..9707e05e 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_response.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_response.go @@ -6,7 +6,6 @@ import ( "context" "fmt" - "github.com/luispater/CLIProxyAPI/v5/internal/misc" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) @@ -19,11 +18,7 @@ func ConvertCodexResponseToOpenAIResponses(ctx context.Context, modelName string if typeResult := gjson.GetBytes(rawJSON, "type"); typeResult.Exists() { typeStr := typeResult.String() if typeStr == "response.created" || typeStr == "response.in_progress" || typeStr == "response.completed" { - instructions := misc.CodexInstructions(modelName) - instructionsResult := gjson.GetBytes(rawJSON, "response.instructions") - if instructionsResult.Raw == instructions { - rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", gjson.GetBytes(originalRequestRawJSON, "instructions").String()) - } + rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", gjson.GetBytes(originalRequestRawJSON, "instructions").String()) } } return []string{fmt.Sprintf("data: %s", string(rawJSON))} @@ -54,11 +49,7 @@ func ConvertCodexResponseToOpenAIResponsesNonStream(_ context.Context, modelName responseResult := rootResult.Get("response") template := responseResult.Raw - instructions := misc.CodexInstructions(modelName) - instructionsResult := gjson.Get(template, "instructions") - if instructionsResult.Raw == instructions { - template, _ = sjson.Set(template, "instructions", gjson.GetBytes(originalRequestRawJSON, "instructions").String()) - } + template, _ = sjson.Set(template, "instructions", gjson.GetBytes(originalRequestRawJSON, "instructions").String()) return template } return ""