fix: update the code based on the review

This commit is contained in:
dataCenter430 2026-03-17 13:35:49 +01:00
parent 8137689660
commit b25ccb04a4
2 changed files with 10 additions and 3 deletions

View file

@ -1020,9 +1020,13 @@ func (al *AgentLoop) runLLMIteration(
providerToolDefs := agent.Tools.ToProviderDefs() providerToolDefs := agent.Tools.ToProviderDefs()
// Determine whether the provider's native web search should replace // Determine whether the provider's native web search should replace
// the client-side web_search tool for this request. // the client-side web_search tool for this request. Only enable when web
// search is actually enabled and registered (so users who disabled web
// access do not get provider-side search or billing).
_, hasWebSearch := agent.Tools.Get("web_search")
useNativeSearch := al.cfg.Tools.Web.PreferNative && useNativeSearch := al.cfg.Tools.Web.PreferNative &&
isNativeSearchProvider(agent.Provider) isNativeSearchProvider(agent.Provider) &&
hasWebSearch
if useNativeSearch { if useNativeSearch {
providerToolDefs = filterClientWebSearch(providerToolDefs) providerToolDefs = filterClientWebSearch(providerToolDefs)

View file

@ -95,7 +95,10 @@ func (p *CodexProvider) Chat(
) )
} }
params := buildCodexParams(messages, tools, resolvedModel, options, p.enableWebSearch) // Respect tools.web.prefer_native: only inject native search when the agent
// loop requested it (options["native_search"]), so prefer_native: false
useNativeSearch := p.enableWebSearch && (options["native_search"] == true)
params := buildCodexParams(messages, tools, resolvedModel, options, useNativeSearch)
stream := p.client.Responses.NewStreaming(ctx, params, opts...) stream := p.client.Responses.NewStreaming(ctx, params, opts...)
defer stream.Close() defer stream.Close()