From 709cf61853a3e1095b2d98c8bd06b3c44114ab47 Mon Sep 17 00:00:00 2001 From: dftian478 <55824328+dftian478@users.noreply.github.com> Date: Sat, 13 Jun 2026 22:51:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20OpenAI=20GPT-5.5=20?= =?UTF-8?q?=E7=9A=84=20Codex=20=E6=8C=87=E4=BB=A4=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/pkg/openai/instructions_test.go | 1 + .../openai_codex_transform_additions_test.go | 2 ++ .../service/openai_codex_transform_test.go | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/backend/internal/pkg/openai/instructions_test.go b/backend/internal/pkg/openai/instructions_test.go index 49240d85b0..5f066997f0 100644 --- a/backend/internal/pkg/openai/instructions_test.go +++ b/backend/internal/pkg/openai/instructions_test.go @@ -25,6 +25,7 @@ func TestCodexBaseInstructionsForModel(t *testing.T) { {"gpt-5.1-codex-max", "You are Codex, based on GPT-5"}, {"gpt-5.2-codex", "You are Codex, based on GPT-5"}, {"gpt-5.5", "You are Codex, a coding agent based on GPT-5"}, + {" GPT-5.5 ", "You are Codex, a coding agent based on GPT-5"}, {"gpt-5.2", "You are GPT-5.2 running in the Codex CLI"}, {"gpt-5.1", "You are GPT-5.1 running in the Codex CLI"}, {"gpt-5", "You are Codex, a coding agent based on GPT-5"}, // 回退到最新(GPT-5.5) diff --git a/backend/internal/service/openai_codex_transform_additions_test.go b/backend/internal/service/openai_codex_transform_additions_test.go index fee4551346..a3dc6bd38c 100644 --- a/backend/internal/service/openai_codex_transform_additions_test.go +++ b/backend/internal/service/openai_codex_transform_additions_test.go @@ -61,6 +61,8 @@ func TestApplyCodexClientMetadata(t *testing.T) { // defaultCodexSynthInstructions:按模型选用真实 Codex base prompt。 func TestDefaultCodexSynthInstructionsModelAware(t *testing.T) { require.True(t, strings.Contains(defaultCodexSynthInstructions("gpt-5-codex"), "You are Codex, based on GPT-5")) + require.True(t, strings.Contains(defaultCodexSynthInstructions("gpt-5.5"), "You are Codex, a coding agent based on GPT-5")) + require.False(t, strings.Contains(defaultCodexSynthInstructions("gpt-5.5"), "You are GPT-5.1 running in the Codex CLI")) require.True(t, strings.Contains(defaultCodexSynthInstructions("gpt-5.2"), "You are GPT-5.2 running in the Codex CLI")) require.True(t, strings.Contains(defaultCodexSynthInstructions("gpt-5.1"), "You are GPT-5.1 running in the Codex CLI")) } diff --git a/backend/internal/service/openai_codex_transform_test.go b/backend/internal/service/openai_codex_transform_test.go index a9ffb0a7b7..e9157377f6 100644 --- a/backend/internal/service/openai_codex_transform_test.go +++ b/backend/internal/service/openai_codex_transform_test.go @@ -1008,6 +1008,21 @@ func TestApplyCodexOAuthTransform_CodexCLI_SuppliesDefaultWhenEmpty(t *testing.T require.True(t, result.Modified) } +func TestApplyCodexOAuthTransform_GPT55SuppliesModelSpecificInstructions(t *testing.T) { + reqBody := map[string]any{ + "model": "gpt-5.5", + "instructions": " ", + } + + result := applyCodexOAuthTransform(reqBody, true, false) + + instructions, ok := reqBody["instructions"].(string) + require.True(t, ok) + require.Contains(t, instructions, "You are Codex, a coding agent based on GPT-5") + require.NotContains(t, instructions, "You are GPT-5.1 running in the Codex CLI") + require.True(t, result.Modified) +} + func TestApplyCodexOAuthTransform_NonCodexCLI_PreservesExistingInstructions(t *testing.T) { // 非 Codex CLI 场景:已有 instructions 时保留客户端的值,不再覆盖