From e73aad2e0afea07a3433a0fa0440f21cac2b339e Mon Sep 17 00:00:00 2001 From: huahai0202 <2023217276@mail.hfut.edu.cn> Date: Mon, 13 Jul 2026 19:35:16 +0800 Subject: [PATCH] fix(codex): require model template for tool search --- sdk/api/handlers/openai/codex_client_models.go | 8 +++++--- sdk/api/handlers/openai/codex_client_models_test.go | 10 ++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/api/handlers/openai/codex_client_models.go b/sdk/api/handlers/openai/codex_client_models.go index d4450481..35149090 100644 --- a/sdk/api/handlers/openai/codex_client_models.go +++ b/sdk/api/handlers/openai/codex_client_models.go @@ -192,10 +192,12 @@ func applyCodexClientSearchToolSupport(entry map[string]any, id string, template return } + if !templateModel { + entry["supports_search_tool"] = false + return + } + if providersForModel == nil { - if !templateModel { - entry["supports_search_tool"] = false - } return } diff --git a/sdk/api/handlers/openai/codex_client_models_test.go b/sdk/api/handlers/openai/codex_client_models_test.go index d8bbe7ed..b2690eb5 100644 --- a/sdk/api/handlers/openai/codex_client_models_test.go +++ b/sdk/api/handlers/openai/codex_client_models_test.go @@ -175,7 +175,7 @@ func TestCodexClientModelsResponse_DisablesSearchToolForSynthesizedModels(t *tes } } -func TestCodexClientModelsResponse_UsesProviderSearchToolSupport(t *testing.T) { +func TestCodexClientModelsResponse_RequiresTemplateAndCodexProvidersForSearchTool(t *testing.T) { providers := map[string][]string{ "new-codex-model": {"codex"}, "gpt-5.5": {"openai-compatible-deepseek"}, @@ -200,12 +200,10 @@ func TestCodexClientModelsResponse_UsesProviderSearchToolSupport(t *testing.T) { bySlug[stringModelValue(model, "slug")] = model } - for _, slug := range []string{"new-codex-model", "gpt-5.6-sol"} { - if got, ok := bySlug[slug]["supports_search_tool"].(bool); !ok || !got { - t.Errorf("%s supports_search_tool = %#v, want true", slug, bySlug[slug]["supports_search_tool"]) - } + if got, ok := bySlug["gpt-5.6-sol"]["supports_search_tool"].(bool); !ok || !got { + t.Errorf("gpt-5.6-sol supports_search_tool = %#v, want true", bySlug["gpt-5.6-sol"]["supports_search_tool"]) } - for _, slug := range []string{"gpt-5.5", "gpt-5.4"} { + for _, slug := range []string{"new-codex-model", "gpt-5.5", "gpt-5.4"} { if got, ok := bySlug[slug]["supports_search_tool"].(bool); !ok || got { t.Errorf("%s supports_search_tool = %#v, want false", slug, bySlug[slug]["supports_search_tool"]) }