feat(tool): add Brave Search as a selectable web_search provider (#294) - #324
Merged
franciscojavierarceo merged 3 commits intoSep 17, 2026
Merged
franciscojavierarceo merged 3 commits into
franciscojavierarceo merged 3 commits into
Conversation
…m-project#294) Phase 2 of vllm-project#291. Add `tool/web_search/brave.rs` behind the typed provider contract from Phase 1 and make the backend selectable through `AGENTIC_WEB_SEARCH_PROVIDER` / `[web_search] provider`. - Brave requests use `GET /res/v1/web/search` with `result_filter=web,news` and `X-Subscription-Token`; `Accept-Encoding` is never sent because the core reqwest build has no gzip support. - Adapt the shared tool contract: apply `allowed_domains` / `blocked_domains` client-side through `DomainFilter`, clamp `count` to 20, render `freshness` as `pd`/`pw`/`pm`/`py`, map `language` to `search_lang`, and ignore the You.com-specific livecrawl arguments. - Fail 401/403 naming `BRAVE_API_KEY` without echoing the body; fail 429 without retrying and surface `Retry-After` (or `X-RateLimit-Reset`). - Add `[web_search] max_concurrent_queries` and `AGENTIC_WEB_SEARCH_MAX_CONCURRENT_QUERIES`; Brave defaults to one in-flight request for its free-plan rate limit, You.com keeps inheriting `max_concurrent_gateway_calls`. - Resolve the endpoint as `AGENTIC_WEB_SEARCH_BASE_URL`, then `YOU_API_BASE_URL` (You.com only), then the file, then the provider default; generated config files record the selected provider. - Serialize `metadata[].provider` for non-default providers only, so You.com output and the recorded Messages cassettes stay byte-identical. - Make `WebSearchProviderConfig` non-exhaustive with `with_provider` and `with_max_concurrent_queries` builders so later providers are additive. Claude-Session: https://claude.ai/code/session_01EsbCF1Smauv41qnpnqYvfz Signed-off-by: Zheng Lu <Lz429671594@gmail.com>
Zheng-Lu
requested review from
bbrowning,
franciscojavierarceo,
haoshan98,
jiahuei,
leseb,
maralbahari,
noobHappylife,
qandrew and
tjtanaa
as code owners
September 17, 2026 16:35
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
franciscojavierarceo
approved these changes
Sep 17, 2026
franciscojavierarceo
left a comment
Collaborator
There was a problem hiding this comment.
patched provider switching in generated configs and HTTP-date Retry-After handling, with regression tests. the provider/configuration tests, Clippy, and pre-commit checks pass locally. Brave HTTP behavior is covered by mocks; no live Brave run was performed.
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
franciscojavierarceo
approved these changes
Sep 17, 2026
7 tasks
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
Closes #294 (Phase 2 of #291).
Implements the Brave Search API provider behind the typed
WebSearchProvidercontract established in Phase 1 (#293), making search backends cleanly selectable viaAGENTIC_WEB_SEARCH_PROVIDER(environment) or[web_search].provider(configuration file), while keeping default You.com behavior and recorded cassettes byte-identical.Key Implementation Details
Provider Implementation (
crates/agentic-server-core/src/tool/web_search/brave.rs):GET {base_url}/res/v1/web/searchwithresult_filter=web,newsandX-Subscription-Token.text_decorations=falseso the LLM receives clean, unadorned snippet text without raw<strong>HTML tags.Accept-Encoding: gzip(corereqwestlacks gzip decompression).freshnessaccurately: supports both short codes (pd,pw,pm,py) AND date ranges (YYYY-MM-DDtoYYYY-MM-DD).countto the Brave 20-result limit withtracing::debug!.BRAVE_API_KEYwithout secret leaks) and 429 (surfacesRetry-AfterorX-RateLimit-Reset).Concurrency & Rate Limiting:
AGENTIC_WEB_SEARCH_MAX_CONCURRENT_QUERIESand[web_search].max_concurrent_queriesas specified in RFC [RFC] Pluggable Web Search Providers and Typed Result Normalization #291 / Issue [Feature] Add Brave Search as a selectable web_search provider #294.Wire Compatibility & RFC [RFC] Pluggable Web Search Providers and Typed Result Normalization #291 Q5 Resolution:
"provider": "brave"inmetadata[].#[serde(skip_serializing_if = "WebSearchProviderKind::is_you")]to ensure existing You.com output and recorded Messages cassettes remain 100% byte-identical.Zero Extra Dependencies & Non-Breaking API:
strumdependency added; uses standard libraryFromStr).WebSearchProviderConfig::newbackward-compatible; introduces fluent.with_provider(...)/.with_max_concurrent_queries(...)builders andWebSearchHandler::from_config(...).Testing & Documentation:
crates/agentic-server-core/tests/web_search_brave_test.rscovering 200 OK (web+news), empty results, domain filtering, 401/403, 429 withRetry-After/X-RateLimit-Reset, batched query serialization, and concurrency overrides.README.md,docs/deploying/README.md,docs/deploying/kubernetes.md,CHANGELOG.md, andARCHITECTURE.md.Review follow-up: keep provider credentials unpinned in generated configs so provider switches select the matching default API-key variable, preserve HTTP-date
Retry-Aftervalues verbatim, and split shared provider types/config resolution into focused modules to pass the production file-size checks.Test Plan
Validation after the review patch:
After merging fix: preserve and verify image input through Responses #263 and fix(mcp): follow tools/list pagination cursors #311, the integrated tree exactly matches the combined checkout with 1,532 passing workspace tests (9 ignored) and passing launcher contract tests. All pre-commit hooks passed again after baseline reconciliation.
60 core tests matching
web_searchpassed.10 Brave integration tests and 25 common/You integration tests passed.
6 configuration-resolution tests passed.
Provider-switch and HTTP-date
Retry-Afterregressions failed before their fixes and passed afterward.cargo clippy --all-targets -- -D warningspassed.pre-commit run --all-filespassed, including formatting and production file-size checks.New Brave coverage uses local Axum HTTP mocks. No live Brave provider call or new Brave cassette was recorded during review.