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 时保留客户端的值,不再覆盖