From 351ecf018293f1ff752f9ccc90c3bc15ac95d45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Wed, 10 Jun 2026 17:36:53 +0800 Subject: [PATCH 1/3] fix(openai_compat): add ok check for native_search type assertion --- pkg/providers/openai_compat/provider.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index ff30d49c6..37c34aa04 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -154,7 +154,8 @@ func (p *Provider) buildRequestBody( } // When fallback uses a different provider (e.g. DeepSeek), that provider must not inject web_search_preview. - nativeSearch, _ := options["native_search"].(bool) + nativeSearch, ok := options["native_search"].(bool) + _ = ok nativeSearch = nativeSearch && isNativeSearchHost(p.apiBase) if len(tools) > 0 || nativeSearch { requestBody["tools"] = buildToolsList(tools, nativeSearch) From 409cc051e7eed36b020c1825b4c2ae20396762df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Fri, 12 Jun 2026 11:23:13 +0800 Subject: [PATCH 2/3] fix(openai_compat): log warning instead of silently discarding native_search ok check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the no-op _ = ok with a warning log when native_search has an unexpected type. When the type assertion fails, nativeSearch already defaults to false, which is conservative — but the caller should know their option was malformed. --- pkg/providers/openai_compat/provider.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index 37c34aa04..ecc348441 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -155,7 +155,14 @@ func (p *Provider) buildRequestBody( // When fallback uses a different provider (e.g. DeepSeek), that provider must not inject web_search_preview. nativeSearch, ok := options["native_search"].(bool) - _ = ok + if !ok { + // If the option is present but not a bool, log a warning and + // treat it as false — web_search_preview must not be injected + // when the caller cannot express a well-typed intent. + if _, present := options["native_search"]; present { + log.Printf("[openai_compat] native_search option has unexpected type %T, ignoring", options["native_search"]) + } + } nativeSearch = nativeSearch && isNativeSearchHost(p.apiBase) if len(tools) > 0 || nativeSearch { requestBody["tools"] = buildToolsList(tools, nativeSearch) From d26e4eca7dff78de68eca06dbae992114719aa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Fri, 12 Jun 2026 13:44:34 +0800 Subject: [PATCH 3/3] chore(openai_compat): fix golines formatting for CI linter --- pkg/providers/openai_compat/provider.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index ecc348441..3f71cfd01 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -160,7 +160,10 @@ func (p *Provider) buildRequestBody( // treat it as false — web_search_preview must not be injected // when the caller cannot express a well-typed intent. if _, present := options["native_search"]; present { - log.Printf("[openai_compat] native_search option has unexpected type %T, ignoring", options["native_search"]) + log.Printf( + "[openai_compat] native_search option has unexpected type %T, ignoring", + options["native_search"], + ) } } nativeSearch = nativeSearch && isNativeSearchHost(p.apiBase)