fix(opencode): let a pinned websearch provider enable the tool for any provider - #44343
fix(opencode): let a pinned websearch provider enable the tool for any provider#44343sahiljagtap08 wants to merge 1 commit into
Conversation
Good refactor — moving the
Otherwise clean and ready. |
…ority Replace whitelist assertions with the B1-B8 matrix: - default-on for arbitrary providers, opt-out via websearch.enabled=false (config wins over managed-provider status) - backend pins: config.websearch.provider > OPENCODE_WEBSEARCH_PROVIDER > legacy flags > per-session split; 'auto' behaves like no pin; invalid env values are ignored without crashing (review note in anomalyco#44343) - legacy OPENCODE_ENABLE_EXA logs a one-shot deprecation warning
…ority Replace whitelist assertions with the B1-B8 matrix: - default-on for arbitrary providers, opt-out via websearch.enabled=false (config wins over managed-provider status) - backend pins: config.websearch.provider > OPENCODE_WEBSEARCH_PROVIDER > legacy flags > per-session split; 'auto' behaves like no pin; invalid env values are ignored without crashing (review note in anomalyco#44343) - legacy OPENCODE_ENABLE_EXA logs a one-shot deprecation warning
Issue for this PR
Closes #44307
Type of change
What does this PR do?
The websearch tool is stripped from the tool list for every provider that is not opencode or opencode-go, unless
OPENCODE_ENABLE_EXAorOPENCODE_ENABLE_PARALLELis set.OPENCODE_WEBSEARCH_PROVIDERalready pins the search backend, but it did not count as an enablement signal, so custom and local providers (Ollama, LM Studio, anything openai-compatible) could pin a backend and still never receive the tool.This makes a pinned
OPENCODE_WEBSEARCH_PROVIDER=exa|parallelalso enable the tool, which gives custom providers one documented env var to turn websearch on. The env read moves out ofselectWebSearchProviderintoRuntimeFlagsnext to the existing exa and parallel flags, so validation happens in one place and the function is testable without touchingprocess.env. Defaults are unchanged: without any of the three env vars, only opencode and opencode-go get the tool.Also updates the tools doc, which only mentioned
OPENCODE_ENABLE_EXAand did not mention that this works for any provider.How did you verify your code works?
Extended the existing websearch tests:
webSearchEnabledreturns true for non opencode providers when a backend is pinned and stays false otherwise, andselectWebSearchProviderhonors the pinned backend over the exa and parallel flags.bun test test/tool/in packages/opencode: 341 pass. Typecheck and oxlint are clean.Screenshots / recordings
Not a UI change.
Checklist