feat(web_search): add provider arg to force a specific engine#1108
Open
mozaa-solana wants to merge 1 commit intonextlevelbuilder:devfrom
Open
feat(web_search): add provider arg to force a specific engine#1108mozaa-solana wants to merge 1 commit intonextlevelbuilder:devfrom
provider arg to force a specific engine#1108mozaa-solana wants to merge 1 commit intonextlevelbuilder:devfrom
Conversation
Currently the web_search tool resolves a tenant-configured provider
chain (e.g. tavily → exa → brave) and stops at the first success.
That's the right default for cost/latency, but it makes cross-engine
corroboration impossible at the agent level: the caller has no way to
ask "search the same query on Exa specifically" once Tavily has
already returned a hit.
Add an optional `provider` argument. When set, the chain is narrowed
to the named provider (case-insensitive); other providers are not
queried. The first-success-wins fallback is preserved when the arg
is omitted.
Use case (concrete): a research agent verifying source freshness
calls web_search twice for the same query — once with provider="tavily"
and once with provider="exa" — and compares the URLs returned. URLs
that appear in both engines are high-confidence original primary
sources; URLs only in one signal a republish or low-circulation outlet
worth verifying further.
Other changes:
- Cache key now includes the requested provider so per-engine
results don't collide. Without this, the second call would just
replay the first engine's cached result, defeating the purpose.
- Unknown provider returns a clear error listing what IS configured
for the tenant — better DX than a silent no-op.
Tests: 5 new cases covering narrowing, case-insensitivity, unknown
provider, default first-success behaviour preservation, and cache
isolation across providers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Currently
web_searchresolves a tenant-configured provider chain (e.g. tavily → exa → brave) and stops at the first success. That's the right default for cost/latency, but it makes cross-engine corroboration impossible at the agent level: the caller has no way to ask "search the same query on Exa specifically" once Tavily already returned a hit.This PR adds an optional
providerargument. When set, the chain is narrowed to the named provider (case-insensitive); other providers are not queried. First-success-wins fallback is preserved when the arg is omitted.Concrete use case
A research agent verifying source freshness:
web_search(query=\"Solana DEX volume\", freshness=\"pd\", provider=\"tavily\")web_search(query=\"Solana DEX volume\", freshness=\"pd\", provider=\"exa\")web_fetchpage metadata.Without
provider, both calls return the same cached Tavily payload and the corroboration is meaningless.Changes
internal/tools/web_search.goproviderarg inParameters().requestedProviderso per-engine results don't collide.internal/tools/web_search_provider_param_test.go(new)Backward compatibility
Fully backward-compatible —
provideris optional. Existing callers (and existing cached entries during rollout) continue to work because the cache key change only affects new writes; old keys age out via TTL.Test plan
go build ./...cleango test ./internal/tools/...passes (new + existing)Related
Used by the c02-choros content-research agent (Max) to implement multi-layer source-freshness verification — agent calls each engine separately and cross-checks URLs to detect republished/syndicated content slipping past Tavily/Exa's date filters. Currently shipped in our fork (
mozaa-solana/goclaw); upstreaming so the capability is broadly available.