Skip to content

chore: model Messages tool declarations as typed variants - #431

Merged
haoshan98 merged 3 commits into
vllm-project:mainfrom
skyloevil:codex/messages-tool-types
Oct 16, 2026
Merged

haoshan98 merged 3 commits into
vllm-project:mainfrom
skyloevil:codex/messages-tool-types

Conversation

@skyloevil

@skyloevil skyloevil commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 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 main at 8d6fa8421bf1df8a0419baf005be66cdde748870, including #424. Following the version compatibility review, 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 feat: accept later web search and web fetch versions on /v1/messages #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 feat: accept later web search and web fetch versions on /v1/messages #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.

/// 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(_)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@haoshan98
haoshan98 merged commit 13e67aa into vllm-project:main Oct 16, 2026
15 checks passed
maralbahari added a commit that referenced this pull request Oct 27, 2026
## 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]>
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.

4 participants