Skip to content

feat: accept later web search and web fetch versions on /v1/messages - #424

Merged
franciscojavierarceo merged 2 commits into
vllm-project:mainfrom
StevenWang-CY:feat-messages-later-web-tool-versions
Oct 10, 2026
Merged

franciscojavierarceo merged 2 commits into
vllm-project:mainfrom
StevenWang-CY:feat-messages-later-web-tool-versions

Conversation

@StevenWang-CY

@StevenWang-CY StevenWang-CY commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #419. 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 every one of them with HTTP 400 on /v1/messages and /v1/messages/count_tokens.

The later versions add dynamic filtering: the tool is called from Anthropic's code execution, and their allowed_callers defaults to the code execution caller only (server tools guide). 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. The upstream sees exactly what it sees for web_search_20250305 / web_fetch_20250910, and the gateway executes the calls under the same max_uses budgets, domain policy, and URL rules.
  • A declaration without "direct", whether allowed_callers is absent, empty, or lists only a code execution caller, is rejected with a 400 that names allowed_callers and 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"].
  • A list that names "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:

Setting Versions Gateway behaviour
use_cache web_fetch_20260309, web_fetch_20260318 Honoured for both values: the built-in fetcher keeps no cache of fetched pages.
response_inclusion web_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). On web_search, which defines no use_cache and response_inclusion only from web_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_config read a declaration's allowed_domains, blocked_domains, and user_location only 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_tokens forwards the rewritten body only when normalize_native_server_tools_for_upstream reports a change, and that report came from two predicates, of which the web search one matched only web_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_VERSIONS and NATIVE_WEB_FETCH_VERSIONS list the executed versions as NativeToolVersion entries, each recording what it defines beyond the basic version as Anthropic documents it: dynamic filtering, use_cache, response_inclusion. NativeToolVersion::find looks 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 the web_fetch name go through the same checks and handlers on every version.
  • tool/declaration.rs: web_search_config reads the shared settings of every listed version.
  • Docs: the web search and web fetch sections and the [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 refused web_search settings, the basic versions' caller refusal, and the supported versions now listed when an unlisted version is refused); the Support the web_fetch tool 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 omit allowed_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 replaying server_tool_use blocks remains #409.

Test Plan

  • Adapter unit tests: the version lists equal a table written out from Anthropic's documentation, independently of the production lists, and the behaviour tests iterate that table. Every version is rewritten into its basic function tool with the same request-wide budget. An empty or code-execution-only allowed_callers is 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_cache and response_inclusion are accepted exactly where the table says and refused elsewhere with the exact message, and null, 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 named web_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_upstream reports the rewrite of every version.
  • Registry unit tests: every web search version carries its domain list and location into the registry, every web fetch version carries its settings, and a plain function named web_search carries none.
  • Core loop tests: every web search version runs as the basic search over JSON and SSE (the search backend receives the domain filter and the country, the call stays hidden, and the upstream receives the identical tool for all three versions); every web fetch version runs as the basic fetch over JSON and SSE with use_cache and response_inclusion where defined; every web fetch version's max_uses refuses a second fetch with max_uses_exceeded; a later version's blocked_domains refuses the page before any request is made.
  • HTTP tests: count_tokens counts 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 on count_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-wide max_uses budget over HTTP JSON and SSE.
  • Red control: on unmodified main (5216d59), the thirteen new and changed integration and HTTP tests that exercise the later versions or the new refusals fail, and the 61 other tests in those six test binaries pass, among them the four basic-version HTTP tests whose shared helpers this PR parametrized. Each failure is main's current behaviour: main refuses every later version as unsupported (unsupported web_search tool type 'web_search_20260209', an HTTP 400 over HTTP), or words the refusal the test pins differently.
  • Mutation testing: each of 34 mutants makes at least one test fail: every acceptance rule and the call that applies it on each tool, every capability field of the version table and the removal of a listed version, the exact match of a declared type, the registry's lookup, the count_tokens rewrite report and its disabled-fetcher check, a later version skipping a shared check or the web_fetch name check, and the wording of the caller, undefined-setting, and unsupported-version refusals.
  • Real-binary e2e: the agentic-server binary against a mock upstream that rejects tools without input_schema the way vLLM does, a mock search provider, and a page origin, over JSON, SSE, and count_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 ignores use_cache and response_inclusion on web_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 (including rust-file-sizes with RUST_FILE_SIZE_BASE=origin/main), cargo fmt -- --check, cargo clippy --all-targets -- -D warnings, and cargo test --no-fail-fast (91 test binaries and 4 doc-test runs, 2276 tests) pass on the exact head from a clean worktree.

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]>
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]>
@franciscojavierarceo
franciscojavierarceo merged commit 8d6fa84 into vllm-project:main Oct 10, 2026
20 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept newer web search and web fetch versions on /v1/messages when dynamic filtering is off

3 participants