feat(proxy): run web search locally when upstream lacks it - #127
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #127 +/- ##
==========================================
+ Coverage 94.95% 95.01% +0.05%
==========================================
Files 22 26 +4
Lines 4620 4950 +330
Branches 1325 1432 +107
==========================================
+ Hits 4387 4703 +316
- Misses 233 247 +14
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eff62e1695
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
orangeboyChen
force-pushed
the
feat/local-websearch
branch
3 times, most recently
from
September 15, 2026 15:19
7da1e69 to
907f336
Compare
CodeBuddy has no equivalent of the server-side search tools that Anthropic (web_search_20260209 / web_search_20250305) and the Responses API (web_search_preview) expose, so clients declaring them got no search at all. The proxy now swaps those declarations for a plain web_search function, executes the query itself, and feeds the findings back; the model answers normally and the client never learns the search ran locally. Search runs through a pluggable provider registry with SearXNG as the first implementation. Adding a backend means one provider file and one entry in the factory list, with no changes to the proxy loop. SearXNG is configured through the environment, since a search instance is deployment infrastructure rather than a per-request preference. The "Enable local web search" console setting only appears when a backend is configured, and stays forced off otherwise so a deployment cannot advertise a tool it cannot execute. Two subtleties the wire protocol imposes: - web_search_preview has no function schema, so Responses tool translation drops it before the loop ever runs. It is now emitted as a function when a backend is configured, including inside namespaces. - A turn mixing a search call with client-owned calls cannot be continued locally, since re-issuing it with only search results leaves those calls unanswered and upstream rejects the transcript. The findings are folded into the message text and the outstanding calls are handed back to the client. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
orangeboyChen
force-pushed
the
feat/local-websearch
branch
from
September 15, 2026 15:29
907f336 to
6f24030
Compare
orangeboyChen
enabled auto-merge (squash)
September 15, 2026 15:55
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.
What this does
Anthropic (
web_search_20260209) and the Responses API (web_search_preview) both delegate web search to the provider. CodeBuddy has no equivalent, so requests carrying those tools either failed or silently lost the tool.When a client declares a search tool and the new setting is on, the proxy swaps it for a plain
web_searchfunction, runs the query through a local search backend, and appends the results as a tool message. The model answers normally and the client never sees the substitution.Settings
Adds 启用本地 WebSearch / Enable local web search to the console, described as performing WebSearch locally in Codebuddy2API. It renders as a switch rather than a text input.
The option only appears when
SEARXNG_URLis set — hiding the label keeps it out of both the rendered form and the save payload, so an unconfigured deployment cannot enable a feature with nothing behind it.getActiveConfigre-checks per request, so a deployment that later drops the variable stops advertising the tool.Pluggable backends
Search sits behind a
WebSearchProviderinterface (lib/server/search/) with SearXNG as the first implementation. Adding another backend means adding one provider file and one entry inresolveProvider— the proxy loop does not change. Configuration is env-only, since a search instance is deployment infrastructure rather than a per-request preference:Behavior notes
web_search_preview, and a plain function namedweb_searchare all recognised.tool_choiceis relaxed toautoafter the first turn. If the budget is spent while the model still wants to search, the tool is withdrawn for one final call so the request terminates with an answer instead of an unresolved tool call.Verification
lint,format:check,typecheck,build, and the full suite (344 tests, 23 files) pass. Coverage 94.2% statements / 87.9% branches against the 90/90/70 thresholds; patch branch coverage 93.0% against the 90% target.