fix: allow concurrent streamable http requests - #1186
Draft
nickcoai wants to merge 2 commits into
Draft
Conversation
nickcoai
force-pushed
the
agent/configurable-streamable-http-parallelism
branch
from
August 18, 2026 15:55
fac20e9 to
fd439b3
Compare
Keep cancellation and replies available while old session POSTs finish. Bound the wait for old POSTs and the replacement initialization handshake. Do not retry interrupted POSTs because the server may have processed them. Add regressions for recovery, queued cancellation, control timeouts, and server replies needed by active requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The streamable http client waits for each POST to finish before starting the next one. When a server returns
application/json, one slow response blocks unrelated requests.Allow several ordinary POSTs to run at once.
StreamableHttpClientTransportConfig::max_concurrent_requestsdefaults to 16. Set it to1to keep ordinary POSTs serial;0is treated as1. An open sse response stream does not count against this limit.Cancellation and replies to server requests use a separate bounded queue with one extra POST slot. The transport signals local cancellation before queuing the notification. Each control POST has a five-second timeout after it starts. Initialization and requests that change the protocol version still run in order with ordinary POSTs; replies remain available when an active request needs them.
If several ordinary POSTs report an expired session (
http 404), they share one recovery attempt. Wait up tosession_recovery_timeoutfor old POSTs to finish, then stop any that remain and returnSessionRecoveryTimeout. Do not retry those interrupted POSTs: the server may have processed them. Create one new session and retry only the POSTs that returnedSessionExpired, at most once each. The timeout defaults to five seconds, and the replacement handshake gets a separate timeout of the same length. Control POSTs and other POST failures are not retried.The shared worker gains an opt-in control queue. The server worker keeps its current behavior. Callers still decide which tools may run at the same time and which need approval.
Tests
Passed locally:
cargo +1.96 test --offline -p rmcp --no-default-features --features client,transport-streamable-http-client --test test_streamable_http_client_concurrency(13 passed)cargo +1.96 test --offline --all-featuresjustfile, with-- --test-threads=1cargo +1.96 clippy --offline --all-targets --all-features -- -D warningscargo +nightly fmt --all -- --checkThe parallel non-local run hit the existing JavaScript test's one-second server startup wait. The isolated test and the complete serial run passed. An additional non-local clippy run reports existing lints in the unchanged server
tower.rs.