Skip to content

Keep tool argument headers and bodies in sync - #15

Open
quinnj wants to merge 1 commit into
mainfrom
perf/tool-header-arguments
Open

quinnj wants to merge 1 commit into
mainfrom
perf/tool-header-arguments

Conversation

@quinnj

@quinnj quinnj commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Modern call_tool encoded known tools' arguments twice: once for Mcp-Param-* headers and again for the request body. Custom JSON lowering could therefore send a routing header such as west with body value east, causing HTTP 400 / HeaderMismatch (-32020) before the tool ran.

Prepare one validated argument snapshot and reuse it for both representations through the existing JSON.JSONText API. Full object validation, duplicate-key/null semantics, schema discovery, omitted arguments, legacy calls and generic JSON-RPC behavior stay covered. This repairs the existing 2026-07-28 header/body contract; no exports or dependencies are added.

Validation:

  • Full suites: 607 checks on Julia 1.13.0; 601 on Julia 1.10.12.
  • 125 focused wire/error/side-effect checks also pass with HTTP 1.11.0 and JSON 1.0.0. The changing-value case fails against main with HTTP 400/-32020.
  • Official conformance runner 0.2.0-alpha.11: custom headers 18/18 and invalid tool headers 11/11.
  • Existing static-server JuliaC --trim=safe compile/run and Documenter build/doctests pass. The native gate does not cover the dynamic modern client.
  • Hosted CI: all 10 jobs and the documentation status are green at 9b31da6f65ba2510ce90a576c20f66748f7c8604, including Linux/macOS/Windows on minimum/current/nightly Julia.

Alternating same-process loopback calls, cached schema, HTTP 2.8 / JSON 1.9, median of 31 pairs:

Julia Routed arguments Full call Allocated bytes
1.13 10,000 integers 2.126 → 1.928 ms 1,319,616 → 1,326,784
1.10 10,000 integers 2.418 → 2.195 ms 4,592,176 → 2,837,408
1.13 1 MiB string 3.474 → 3.284 ms essentially unchanged
1.10 1 MiB string 4.091 → 3.885 ms essentially unchanged

These measurements include client/server JSON handling and actual TCP, excluding discovery, TLS and application work. Small warmed calls were unchanged. The first routed call added approximately 9 ms on Julia 1.13 and 22 ms on 1.10 in three fresh-process pairs; current-runtime numeric calls allocate about 7 KB more. Unrelated host work remained active, so these are bounded measurements, not a general throughput claim.

Co-authored by Codex

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.

1 participant