Repository navigation
feat: accept later web search and web fetch versions on /v1/messages - #424
Merged
franciscojavierarceo merged 2 commits intoOct 10, 2026
Conversation
Claude's native server tools have later versions that Anthropic's docs and SDK examples now use: web_search_20260209 and web_search_20260318, and web_fetch_20260209, web_fetch_20260309, and web_fetch_20260318. The gateway rejected all of them with HTTP 400 on /v1/messages and count_tokens. The later versions add dynamic filtering, which calls the tool from Anthropic's code execution; their allowed_callers defaults to ["code_execution_20260120"]. The gateway does not run code execution, so a declaration whose allowed_callers includes "direct" is accepted and rewritten into the basic version's function tool, and one without it is rejected with a 400 that names allowed_callers and the reason, which is how Anthropic's API answers for models without programmatic tool calling (vllm-project#419). A basic version without "direct" is refused with the same message shape. Each supported version is a NativeToolVersion entry in tool_seam that records what it defines beyond the basic version: dynamic filtering, use_cache, and response_inclusion. The adapter reads those fields instead of comparing version strings. use_cache (web_fetch_20260309 and later) is accepted with either value because the built-in fetcher keeps no cache of fetched pages, and response_inclusion (the _20260318 versions) because it only acts on results that code execution consumed. Either setting on a version that does not define it is refused, including on web_search, which ignored both before, and a version the gateway does not list is refused with the supported versions in the message. Two paths keyed on the basic version only are fixed with it: the registry read a web_search declaration's domain lists and location only for web_search_20250305, so a later version would have run an unfiltered search, and count_tokens decided whether to forward the rewritten body from a predicate that knew only web_search_20250305. The rewrite now reports whether it changed a declaration, and the registry looks the declared type up in the version list. Closes vllm-project#419 Signed-off-by: Chuyue Wang <[email protected]>
StevenWang-CY
requested review from
bbrowning,
franciscojavierarceo,
haoshan98,
jiahuei,
leseb,
maralbahari,
noobHappylife,
qandrew and
tjtanaa
as code owners
October 8, 2026 01:45
Review follow-up for vllm-project#419. A later web_fetch version is held to the name web_fetch like the basic one; use_cache and response_inclusion refuse null and other undocumented values on the versions that define them; every web_fetch version is refused on both endpoints when the operator disables the fetcher; and the refusal of an unlisted type is asserted in full, with the supported versions of its tool. The README example now follows the sentence that introduces the accepted declaration, the CHANGELOG Changed entry names both endpoints, the shared message shape, and the supported-versions list in the unlisted-version refusal, and two doc comments no longer overstate which settings or versions they cover. Signed-off-by: Chuyue Wang <[email protected]>
maralbahari
approved these changes
Oct 9, 2026
haoshan98
pushed a commit
that referenced
this pull request
Oct 16, 2026
## Summary Messages tool declarations currently combine every kind behind an optional string discriminator. Replace that struct with explicit `Function`, `WebSearch`, `WebFetch`, and opaque `Provider` variants, with exhaustive conversion into the existing tool layer. Supported native declarations retain their original protocol version and opaque extension fields; serialization borrows the declaration rather than cloning it. This is the independently reviewable type foundation extracted from #425, following the [typing feedback](#425 (comment)) and [proposed split](#425 (comment)). It does not depend on the MCP connector. MCP history conversions, execution/projection changes, and reference recordings remain separate work; acceptance of the proposed recording follow-up is still under discussion. Rebased onto upstream `main` at `8d6fa8421bf1df8a0419baf005be66cdde748870`, including #424. Following the [version compatibility review](#431 (comment)), classification and request validation now share the exact native-version capability tables in `types/messages/tools/versions.rs`, re-exported at their existing public paths. All three search and four fetch versions retain their declared `type`. Search declarations carry `allowed_domains`, `blocked_domains`, and `user_location` into the registry and execution backend. This preserves #424's direct-call restrictions and version-specific validation; it does not add dynamic filtering or silently support future versions. Preserve the HTTP wire contract, execution ownership, operator aliases, and exact JSON/SSE pass-through. Existing Rust import paths remain available; Rust callers use enum variants instead of the former struct literal. The architecture documents the shared version policy and extension path. ## Test Plan - RED: after rebasing, the retained #424 registry test fails for `web_search_20260209` with `allowed_domains = None`, reproducing the review finding. The repaired test passes for every supported search version, including blocked domains. - `cargo test --workspace`: 2,330 passed, 0 failed, 18 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings`. - `cargo fmt --all -- --check`, `git diff --check`, and all pre-commit hooks using pre-commit 4.4.0. - Classify and round-trip every supported search/fetch version without rewriting its discriminator; preserve opaque unknown versions, including near-miss dates and suffixed known types. - Differential parsing/serialization checks against the pre-refactor shape across 200 kind/name/schema combinations, plus nulls, malformed fields, duplicate keys, and opaque extensions. - Retain #424's registry and HTTP version/caller/capability tests. Expand JSON and SSE execution tests to check allowed and blocked domains separately plus user location for every search version; retain fetch execution tests for every supported fetch version. - OpenAPI schema/Serde agreement and unchanged HTTP JSON/SSE provider-tool forwarding. --------- Signed-off-by: zitian.zhao <[email protected]> Co-authored-by: Francisco Javier Arceo <[email protected]>
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 #419. Claude's native server tools have later versions that Anthropic's docs and SDK examples now use:
web_search_20260209andweb_search_20260318, andweb_fetch_20260209,web_fetch_20260309, andweb_fetch_20260318. The gateway rejected every one of them with HTTP 400 on/v1/messagesand/v1/messages/count_tokens.The later versions add dynamic filtering: the tool is called from Anthropic's code execution, and their
allowed_callersdefaults to the code execution caller only (server tools guide). The gateway does not run code execution, so:allowed_callersincludes"direct"is accepted and rewritten into the basic version's function tool. The upstream sees exactly what it sees forweb_search_20250305/web_fetch_20250910, and the gateway executes the calls under the samemax_usesbudgets, domain policy, and URL rules."direct", whetherallowed_callersis absent, empty, or lists only a code execution caller, is rejected with a 400 that namesallowed_callersand the reason, before anything reaches the upstream:web_search_20260318 allowed_callers must include "direct": dynamic filtering calls the tool from code execution, which this gateway does not run.Anthropic's API answers the same way on models without programmatic tool calling, where these versions require
allowed_callers: ["direct"]."direct"alongside a code execution caller is accepted, the rule the basic versions already follow: the gateway only makes the direct calls the list permits. A basic version whose list omits"direct"is still refused, now with the same message shape and its own reason (this gateway calls the tool only directly, never from code execution).The two settings the later versions add are accepted only on the versions that define them:
use_cacheweb_fetch_20260309,web_fetch_20260318response_inclusionweb_search_20260318,web_fetch_20260318"full"and"excluded"accepted: the setting only governs results that a completed code execution call consumed, and the gateway never calls a tool from code execution.On any other version of either tool, the setting is refused with HTTP 400 naming the declared type (
web_fetch_20250910 does not define use_cache). Onweb_search, which defines nouse_cacheandresponse_inclusiononly fromweb_search_20260318, both settings used to be ignored. A version the gateway does not list is refused with the supported versions in the message, so a future version never runs under rules that may not hold for it.Two paths that were keyed to the basic version
Accepting the later versions in the adapter is not enough on its own; two other paths compared the declared type with
web_search_20250305:tool::declaration::web_search_configread a declaration'sallowed_domains,blocked_domains, anduser_locationonly for the basic version. A later version would have reached the registry without them and run an unfiltered search. It now looks the declared type up in the version list.count_tokensforwards the rewritten body only whennormalize_native_server_tools_for_upstreamreports a change, and that report came from two predicates, of which the web search one matched onlyweb_search_20250305, so a later web search version would have been counted in its raw form, which vLLM rejects. The rewrite now reports whether it rewrote a declaration, and the web search predicate is gone.Implementation
types/messages/tool_seam.rs:NATIVE_WEB_SEARCH_VERSIONSandNATIVE_WEB_FETCH_VERSIONSlist the executed versions asNativeToolVersionentries, each recording what it defines beyond the basic version as Anthropic documents it: dynamic filtering,use_cache,response_inclusion.NativeToolVersion::findlooks a declared type up by exact match.executor/messages_request.rs: the adapter resolves the declared type to its entry and reads those fields, with no comparison of version strings. The shared settings (domain lists,user_location,citations,max_uses,max_content_tokens) and theweb_fetchname go through the same checks and handlers on every version.tool/declaration.rs:web_search_configreads the shared settings of every listed version.[web_fetch]config comment of the README,docs/api/index.md,docs/deploying/README.md,ARCHITECTURE.md, and the CHANGELOG (Unreleased: Added for the versions; Changed for the basic-version constants, the newly refusedweb_searchsettings, the basic versions' caller refusal, and the supported versions now listed when an unlisted version is refused); the Support theweb_fetchtool on/v1/messages#408 entry no longer says the later versions are rejected.The issue mentions an optional operator setting that would run code-execution-only declarations as direct calls instead of rejecting them. This PR does not add it. The Claude Code release checked here (2.1.292) declares only
web_search_20250305, and an application that copies Anthropic's dynamic-filtering examples, which omitallowed_callers, receives a 400 that names the one-line fix, as it would from Anthropic's API on a model without programmatic tool calling. Returning and replayingserver_tool_useblocks remains #409.Test Plan
allowed_callersis refused on every version, and an absent one on the later versions, each with the exact message; the basic versions accept an absent one.use_cacheandresponse_inclusionare accepted exactly where the table says and refused elsewhere with the exact message, andnull, numbers, and other undocumented values are refused where they are defined. The shared settings are judged on every later version exactly as on the basic one, and every web fetch version must be namedweb_fetch. Unlisted types (an unknown stamp, a stamp between two supported versions, a listed version with a suffix) are refused with the exact message, which lists the supported versions.normalize_native_server_tools_for_upstreamreports the rewrite of every version.web_searchcarries none.use_cacheandresponse_inclusionwhere defined; every web fetch version'smax_usesrefuses a second fetch withmax_uses_exceeded; a later version'sblocked_domainsrefuses the page before any request is made.count_tokenscounts all seven versions as their tool's basic function tool; later versions without"direct"are refused with 400 on/v1/messages(JSON and SSE) and oncount_tokens, with the exact message and no upstream request; settings a version does not define, and a basic version without"direct", are refused with the exact message on both endpoints; every web fetch version is refused on both endpoints when the operator disables the fetcher; an unlisted web search version is refused with the supported versions; the later web fetch versions run over HTTP JSON and SSE; the later web search versions run under the same request-widemax_usesbudget over HTTP JSON and SSE.unsupported web_search tool type 'web_search_20260209', an HTTP 400 over HTTP), or words the refusal the test pins differently.count_tokensrewrite report and its disabled-fetcher check, a later version skipping a shared check or theweb_fetchname check, and the wording of the caller, undefined-setting, and unsupported-version refusals.agentic-serverbinary against a mock upstream that rejects tools withoutinput_schemathe way vLLM does, a mock search provider, and a page origin, over JSON, SSE, andcount_tokens: all 89 checks pass on this branch. On main, the 14 basic-version checks pass; 52 of the 57 later-version checks fail, because main refuses every later version as unsupported, and the five that pass only assert that a refused request never reaches the upstream; and all 18 checks of settings a version does not define and of a basic version without"direct"fail: four because main ignoresuse_cacheandresponse_inclusiononweb_search_20250305, eight because it refuses the later version as unsupported, and six because it words the same refusal differently.pre-commit run --all-files(includingrust-file-sizeswithRUST_FILE_SIZE_BASE=origin/main),cargo fmt -- --check,cargo clippy --all-targets -- -D warnings, andcargo test --no-fail-fast(91 test binaries and 4 doc-test runs, 2276 tests) pass on the exact head from a clean worktree.