Skip to content

Reuse warmed TLS on MCP HTTP and WSS reconnects - #679

Closed
justrach wants to merge 4 commits into
mainfrom
cursor/network-efficiency-4ffc
Closed

Reuse warmed TLS on MCP HTTP and WSS reconnects#679
justrach wants to merge 4 commits into
mainfrom
cursor/network-efficiency-4ffc

Conversation

@justrach

@justrach justrach commented Aug 29, 2026

Copy link
Copy Markdown
Owner

The harness was paying extra TLS and sending MCP catalogs uncompressed. Further speedups after this PR do not pay for themselves (see table).

Round-trips / reconnects

  • MCP Auto’s modern tools/list probe and legacy notifications/initialized each built a throwaway std.http.Client.
  • Every WSS dial rescanned the host CA store from disk.
  • Both now reuse process-warmed state (ADR 0043). WS→SSE stays on the Agent’s prewarmed pool.

Payload

  • MCP Streamable HTTP omitted Accept-Encoding. It now advertises gzip/deflate and decodes Content-Encoding.

Left alone
Prompt-cache keys, xAI WS full-resend (ADR 0002), MCP consent, deferred MCP join, OAuth login clients.

Measured (this host, 2026-08-30)

Path Before After Why we stopped
MCP modern connect + next tools/list 2 TCP accepts 1 accept, 2 POSTs keep-alive is the rest
WSS CA disk walk 1 rescan per connect 1 per process a second launch walk is 4–7 ms; cloning the HTTP bundle risks a double-free
MCP tools/list (40-tool fixture) 6110 B raw 320 B gzip (5%) only if the server ignores gzip
WS→SSE latch prewarmed Agent pool unchanged a fresh client adds TLS
xAI / Codex WS body full history unchanged ADR 0002
MCP OAuth / login 401 throwaway client unchanged not on the turn path

Suite: 1760 (+7 reachable tests vs this main). Baseline 1745 unchanged. Tier 1 green on 4589a70. ADR 0043; 0042 is reserved by the sandbox teleport PR.

Open in Web Open in Cursor 

The modern tools/list probe and legacy initialized notify each built a
throwaway HTTP client, so a successful probe's keep-alive died before the
next call. WSS rescanned the host CA store on every dial.

Probe and initialized now use the persistent transport; WSS shares a
process-lifetime CA bundle warmed once. WS→SSE stays on the prewarmed
Agent pool. Loopback test: connect + next list is one TCP accept.
embedFile includes the test body, so a contiguous throwaway-client
string in the assertion always "found" itself. Split the needles.
@justrach
justrach marked this pull request as ready for review August 29, 2026 18:18
Streamable HTTP omitted Accept-Encoding and read the raw body, so a
tools/list catalog crossed uncompressed. Provider POST already decompresses.
Advertise the std client defaults and decode Content-Encoding.

Loopback: a 40-tool list is smaller on the wire than plaintext, and the
client still returns the JSON. ADR 0043 updated.
A second launch CA walk is 4–7ms and OAuth throwaways are login-only;
ADR 0002 blocks shrinking WS bodies. No further code change. Table is
the evidence for stopping.
@justrach

Copy link
Copy Markdown
Owner Author

Folded into release/v0.0.282 (#696). ADR remapped 0043 → 0050 (0043 is Pi SWE). Closing as superseded.

@justrach justrach closed this Aug 31, 2026
@cursor
cursor Bot deleted the cursor/network-efficiency-4ffc branch August 31, 2026 01:30
cursor Bot pushed a commit that referenced this pull request Aug 31, 2026
Complementary to #694 model-HTTP generations: MCP HTTP/WSS keep the
warmed client and accept gzip catalogs. ADR remapped off 0043.

# Conflicts:
#	docs/adr/README.md
#	src/http_warm.zig
#	src/test_hooks.zig
cursor Bot pushed a commit that referenced this pull request Aug 31, 2026
Record the ADR remaps (0049 / 0050) and the extra #694 lifecycle
hardening. Still no tag.
cursor Bot pushed a commit that referenced this pull request Aug 31, 2026
The remote advanced from da6511b with #695 while this tip already had
#697/#679/#694 follow-up and the 1848 ratchet.
cursor Bot pushed a commit that referenced this pull request Aug 31, 2026
Remote 282 advanced with the empty-tools serializer while this tip
already had #697/#679 and the 1848 floor. Notes and leftovers now
match the merged revision. No tag.
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.

2 participants