From 3a230bdfce94f958d6e42b2b9a68bf58dbe2e0ce Mon Sep 17 00:00:00 2001 From: dataCenter430 Date: Sun, 15 Mar 2026 17:18:39 +0100 Subject: [PATCH] config: add prefer_native and NativeSearchCapable for model-native search --- config/config.example.json | 1 + pkg/config/config.go | 6 ++++++ pkg/config/defaults.go | 1 + pkg/providers/types.go | 9 +++++++++ 4 files changed, 17 insertions(+) diff --git a/config/config.example.json b/config/config.example.json index 1c11cd42a..404f08218 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -313,6 +313,7 @@ "allow_write_paths": null, "web": { "enabled": true, + "prefer_native": true, "brave": { "enabled": false, "api_key": "YOUR_BRAVE_API_KEY", diff --git a/pkg/config/config.go b/pkg/config/config.go index 190341224..d431563ba 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -690,6 +690,12 @@ type WebToolsConfig struct { Perplexity PerplexityConfig ` json:"perplexity"` SearXNG SearXNGConfig ` json:"searxng"` GLMSearch GLMSearchConfig ` json:"glm_search"` + // PreferNative controls whether to use provider-native web search when + // the active LLM supports it (e.g. OpenAI web_search_preview). When true, + // the client-side web_search tool is hidden to avoid duplicate search surfaces, + // and the provider's built-in search is used instead. Falls back to client-side + // search when the provider does not support native search. + PreferNative bool `json:"prefer_native" env:"PICOCLAW_TOOLS_WEB_PREFER_NATIVE"` // Proxy is an optional proxy URL for web tools (http/https/socks5/socks5h). // For authenticated proxies, prefer HTTP_PROXY/HTTPS_PROXY env vars instead of embedding credentials in config. Proxy string `json:"proxy,omitempty" env:"PICOCLAW_TOOLS_WEB_PROXY"` diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index dc534d852..252384ea3 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -410,6 +410,7 @@ func DefaultConfig() *Config { ToolConfig: ToolConfig{ Enabled: true, }, + PreferNative: true, Proxy: "", FetchLimitBytes: 10 * 1024 * 1024, // 10MB by default Brave: BraveConfig{ diff --git a/pkg/providers/types.go b/pkg/providers/types.go index 68bbd1e65..1f28bc4ad 100644 --- a/pkg/providers/types.go +++ b/pkg/providers/types.go @@ -44,6 +44,15 @@ type ThinkingCapable interface { SupportsThinking() bool } +// NativeSearchCapable is an optional interface for providers that support +// built-in web search during LLM inference (e.g. OpenAI web_search_preview, +// xAI Grok search). When the active provider implements this interface and +// returns true, the agent loop can hide the client-side web_search tool to +// avoid duplicate search surfaces and use the provider's native search instead. +type NativeSearchCapable interface { + SupportsNativeSearch() bool +} + // FailoverReason classifies why an LLM request failed for fallback decisions. type FailoverReason string