Repository navigation
chore: model Messages tool declarations as typed variants - #431
Conversation
| /// same way for the registry and for the Messages adapter. | ||
| pub(crate) fn web_search_config(tool: &ToolParam) -> WebSearchToolParam { | ||
| if tool.type_.as_deref() != Some(NATIVE_WEB_SEARCH_TYPE) { | ||
| if !matches!(tool, ToolParam::WebSearch(_)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Signed-off-by: zitian.zhao <[email protected]>
Signed-off-by: zitian.zhao <[email protected]>
2c068c7 to
3e56232
Compare
## Summary Share JSON/SSE round decisions (continue gateway execution, return client calls, finish, and client-call `end_turn` correction) and completed `MessagesToolCall` data with typed argument errors. Parse streamed arguments once for history and dispatch while keeping malformed input non-executable. Rebased on current main (`a7dc7b5`). Reuse its registry bindings and `GatewaySchedulerPolicy` (#437), preserving model-order budget admission, permit acquisition/concurrency limits, timeout after permits, tool-stage timing/error status, and cancellation. Existing ingestion validation, live delivery, opaque history and usage remain intact. Follow-up to #431, tracked by #418 ([split plan](#418 (comment))). MCP-specific projection and pending-call continuation remain in #425. Kept as draft for review of this independent refactor. ## Test Plan - 14 shared synthetic scenarios on JSON and SSE cover named/client/mixed/truncated rounds, stop reasons, escaped/Unicode arguments, history and usage. - Messages unit tests: 71 passed, including all 8 existing scheduling/lifecycle tests. JSON/SSE, web-fetch and execution-trace integration targets: 86 passed, including live delivery, cancellation, invalid streams/arguments and typed tool stages. - `cargo test --workspace --locked --no-fail-fast`: 2,723 passed, 0 failed, 18 ignored; includes existing HTTP budget/ownership tests and cassette replays. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, formatting, diff checks and all pre-commit 4.4.0 hooks passed. The first sandboxed unit run could not bind localhost for 4 mock-server tests; the rerun with local-port access passed all 71. No new recordings were added. Feature-enabled Linux and PostgreSQL coverage runs in repository CI. Signed-off-by: zitian.zhao <[email protected]> Co-authored-by: Maral <[email protected]>
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.