chore: model Messages tool declarations as typed variants #431
this check only recognizes web_search_20250305, but #424 is now on main and accepts web_search_20260209 and web_search_20260318. those declarations deserialize as ToolParam::Provider, so web_search_config returns the default and the registry loses their allowed_domains, blocked_domains, and user_location settings before executing the search. we should classify every supported native search version here and keep the registry test from #424 for each version when rebasing.
Thanks for catching this. Fixed in 3e56232 after rebasing onto the latest main, including #424.
Deserialization now uses the same native-version tables as request validation, so all supported search versions are classified as ToolParam::WebSearch. The original version is retained during serialization.
I kept #424’s per-version registry test, added blocked-domain assertions, and expanded the JSON/SSE execution tests to verify domain filters and user location for every supported search version. The supported fetch versions also retain their original types. Existing direct-call restrictions and unsupported-version validation remain covered.
Approved these changes.
maralbahari
skyloevil
Summary
Messages tool declarations currently combine every kind behind an optional string discriminator. Replace that struct with explicit
Function,WebSearch,WebFetch, and opaqueProvidervariants, 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 and proposed split. 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
mainat8d6fa8421bf1df8a0419baf005be66cdde748870, including #424. Following the version compatibility review, classification and request validation now share the exact native-version capability tables intypes/messages/tools/versions.rs, re-exported at their existing public paths. All three search and four fetch versions retain their declaredtype. Search declarations carryallowed_domains,blocked_domains, anduser_locationinto 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
web_search_20260209withallowed_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.