From 220ca45f7465be930f072c226dfd585d88675f95 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Sun, 11 Jan 2026 15:52:21 +0800 Subject: [PATCH] fix(codex): only override instructions when upstream provides them --- .../responses/codex_openai-responses_response.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 95d771d5..c18e573b 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_response.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_response.go @@ -19,8 +19,10 @@ 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 := selectInstructions(originalRequestRawJSON, requestRawJSON) - rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", instructions) + if gjson.GetBytes(rawJSON, "response.instructions").Exists() { + instructions := selectInstructions(originalRequestRawJSON, requestRawJSON) + rawJSON, _ = sjson.SetBytes(rawJSON, "response.instructions", instructions) + } } } out := fmt.Sprintf("data: %s", string(rawJSON)) @@ -39,7 +41,9 @@ func ConvertCodexResponseToOpenAIResponsesNonStream(_ context.Context, modelName } responseResult := rootResult.Get("response") template := responseResult.Raw - template, _ = sjson.Set(template, "instructions", selectInstructions(originalRequestRawJSON, requestRawJSON)) + if responseResult.Get("instructions").Exists() { + template, _ = sjson.Set(template, "instructions", selectInstructions(originalRequestRawJSON, requestRawJSON)) + } return template }