← Back to Pull requests

chore: model Messages tool declarations as typed variants #431

Merged
skyloevil merged 13 files (883 lines) on Oct 16, 2026 04:34 UTC
View on GitHub
skyloevil skyloevil commented on Oct 10, 2026 03:56 UTC
Author

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 #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.
  • Diff: 883 lines (+667 / -216) across 13 files Reviewer: maralbahari Review duration: 8677m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.66) × (1 − Review Confidence (0.80)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 883 lines diff across 13 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.75 · 2 substantive comment(s)
    0.75
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    79%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    4 items
    franciscojavierarceo franciscojavierarceo commented on code on Oct 10, 2026 13:02 UTC
    Code Review
    crates/agentic-server-core/src/tool/declaration.rs:1
    @@ -147,16 +155,17 @@ fn map_tool(tool: &ToolParam, map: &GatewayToolMap) -> Option<ToolDeclaration> {
     /// The per-request settings of a native `web_search` declaration, read the
     /// 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(_)) {

    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.

    skyloevil skyloevil commented on code on Oct 11, 2026 07:16 UTC
    Code Review
    crates/agentic-server-core/src/tool/declaration.rs:1
    @@ -147,16 +155,17 @@ fn map_tool(tool: &ToolParam, map: &GatewayToolMap) -> Option<ToolDeclaration> {
     /// The per-request settings of a native `web_search` declaration, read the
     /// 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(_)) {

    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.

    maralbahari maralbahari approved these changes on Oct 15, 2026 06:57 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    skyloevil skyloevil
    Labels
    risk: low confidence: 79.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.6% (HIGH) · Higher = larger blast radius
    65.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 79.6% · Lower = rushed or shallow review
    79.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 13.4% · Safe to merge
    13.4%