# What happens when an instance multiplexes MCP servers over one HTTP stream and a mid-stream tool result arrives after the transport has already been reaped **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that compose multiple MCP servers behind a single HTTP-native multiplexer (SSE or chunked JSON-RPC over one connection pool) and reuse that transport across tool calls. Does not apply to one-server-per-process stdio MCP topologies or to runtimes that open a fresh connection per tool invocation. ## Core Distinction The failure is not "the tool call failed." The failure is that a *successful* tool result from server B is delivered onto a transport whose read side has been reaped because server A's call on the same multiplexed stream timed out first. The multiplexer treats the connection as a unit of liveness; MCP treats each `(server, request_id)` pair as its own unit of liveness. When those two liveness models disagree, the runtime observes a tool call as "lost" even though the remote MCP server executed it and wrote a valid `result` frame. The distinction that matters operationally: **transport death and request death are decoupled events, and the multiplexer's reaper conflates them.** ## What Was Observed A runtime composed three MCP servers — `fs` (filesystem, fast), `search` (network-bound, p50 800ms, p99 9s), and `code` (sandbox, 1–4s) — behind one HTTP/2 connection with a shared SSE read loop. Requests were interleaved: `search.query` was dispatched, then 200ms later `code.execute` was dispatched on the same stream because the planner decided the two were independent. The `search` call exceeded the multiplexer's per-connection idle-read deadline (10s, configured against the *fastest* server). The reaper closed the SSE stream and marked the connection dead. At t=10.4s the `code.execute` result frame arrived on the wire — the server had finished at 3.1s and buffered the frame behind the still-open `search` response in the same connection's write queue. The reaper had already torn down the read loop, so the frame was parsed by nobody. The runtime's `code` tool call was recorded as `TransportClosed`, the planner retried it, and the sandbox executed the same side-effecting script a second time. The observable signature in logs: ``` [transport] conn=7 idle_read_ms=10012 -> reaping [transport] conn=7 state: OPEN -> DEAD [mcp:search] req=41 -> no response (transport dead) [mcp:code] req=42 -> frame received on dead conn, dropped [mcp:code] req=42 -> retry dispatched on conn=9 [mcp:code] req=42 -> result OK (duplicate execution) ``` The second execution is the operational injury. The first is a latency artifact; the second is a correctness violation caused by the retry policy having no knowledge that the original request had *completed server-side*. ## Condition of Validity This boundary is reachable only when all of the following hold simultaneously: 1. **Shared transport.** Two or more MCP server sessions are multiplexed onto one HTTP connection (or one connection-pool member with a single read loop). If each server has its own connection, per-server timeouts are independent and the reaper cannot cross-contaminate. 2. **Head-of-line coupling.** The slow server's response occupies the read loop or the connection's response queue, so the fast server's frame is behind it in ordering. HTTP/2 multiplexes streams but a single SSE read loop over one stream does not; if the multiplexer uses one SSE stream per connection rather than one per request, HOL blocking is structural. 3. **Timeout calibrated to the wrong server.** The idle-read deadline is set from the fastest or median server's latency distribution, not the slowest, or it is a single global value. 4. **Retry-on-transport-error policy without idempotency keys.** The runtime retries `TransportClosed` unconditionally, and MCP requests carry no client-generated idempotency token that the server could deduplicate on. 5. **Side-effecting tool.** The retried tool mutates state (writes a file, executes code, sends a message). Read-only tools make the failure a latency bug, not a correctness bug. Remove any one condition and the failure collapses into a benign retry or a clean error. The invariant that must hold to prevent it: **a multiplexed transport may be reaped only when every in-flight request on it has reached a terminal state, or the reaper must synthesize a terminal `TransportClosed` per in-flight request *and* the retry layer must treat that synthetic terminal as non-retryable for non-idempotent tools.** ## Decision Boundary The runtime must decide, per in-flight request at reap time, between three actions: - **Preserve and drain.** Keep the read loop alive until all in-flight requests resolve or hit their *per-request* deadline. Correct but risks unbounded connection lifetime if one server hangs. - **Synthesize terminal + suppress retry.** Reap the transport, mark every in-flight request `TransportClosed`, and *do not retry* those whose tool is non-idempotent. Correct but converts a recoverable timeout into a user-visible failure. - **Synthesize terminal + retry with idempotency key.** Reap, mark terminal, retry with a client-generated `idempotency_key` that the MCP server deduplicates on. Correct and recoverable, but requires server-side support that most MCP servers do not implement. The boundary is crossed when the runtime picks option 3's *behavior* (retry) without option 3's *precondition* (idempotency key). That is the default configuration of nearly every MCP multiplexer shipped to date: retry-on-transport-error is on, idempotency keys are absent, and the reap is connection-scoped rather than request-scoped. The second boundary is timeout calibration. A single idle-read deadline across heterogeneous servers is only safe if it is set to `max(p99 across all servers) + margin`. Setting it to the median is the trigger condition for the failure above. Per-request deadlines (carried as MCP request metadata or as the multiplexer's per-request timer) decouple the two liveness models and are the structural fix. ## Operational Effect Downstream of a crossed boundary, the agent's reasoning loop sees a `TransportClosed` for a call that actually succeeded. Two compounding effects: 1. **Duplicate side effects.** The retry re-executes the tool. For `code.execute` this means the script ran twice; for `fs.write` the second write may clobber the first; for a messaging tool the recipient gets two messages. The agent has no way to observe the duplication because both executions return `OK`. 2. **False negative in the planner's world model.** The planner records the first attempt as failed. If it uses failure counts to escalate or to switch strategies, it now believes a working tool is flaky and may route around it — degrading the plan for reasons that are purely transport artifacts. The guardrail is a two-part invariant enforced in the multiplexer: (a) per-request terminal states are synthesized at reap time, never inferred from connection state, and (b) the retry layer consults a per-tool idempotency declaration before retrying a synthesized terminal. A tool that does not declare idempotency is retried zero times on transport death and surfaced to the planner as a hard failure, which is the honest signal. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Optional class TransportReapError(RuntimeError): """Raised when a multiplexed transport is reaped with live in-flight requests.""" pass class RequestState(Enum): IN_FLIGHT = "in_flight" RESOLVED = "resolved" SYNTHETIC_CLOSED = "synthetic_closed" @dataclass class InFlightRequest: server: str request_id: int tool_name: str idempotent: bool state: RequestState = RequestState.IN_FLIGHT idempotency_key: Optional[str] = None @dataclass class MultiplexedTransport: conn_id: int in_flight: Dict[int, InFlightRequest] = field(default_factory=dict) dead: bool = False def reap(self) -> list: """ Reap the transport. Every in-flight request must transition to a synthetic terminal state. A request that is still IN_FLIGHT after reap is a continuity violation: the runtime will retry it without an idempotency key and may duplicate side effects. """ self.dead = True closed = [] for req in self.in_flight.values(): if req.state is RequestState.IN_FLIGHT: req.state = RequestState.SYNTHETIC_CLOSED closed.append(req) for req in closed: if not req.idempotent and req.idempotency_key is None: # Non-idempotent request died on the wire with no dedup token. # Retrying would duplicate the side effect; the only safe # action is to surface a hard failure to the planner. raise TransportReapError( f"conn={self.conn_id} reaped with non-idempotent " f"in-flight request server={req.server} " f"req={req.request_id} tool={req.tool_name}; " f"retry would duplicate side effect" ) return closed def resolve(self, request_id: int) -> None: req = self.in_flight.get(request_id) if req is None: raise TransportReapError( f"conn={self.conn_id} resolve for unknown req={request_id}" ) if self.dead: # Late frame arriving after reap. Dropping it silently is the # observed bug; raising forces the caller to reconcile. raise TransportReapError( f"conn={self.conn_id} late result for req={request_id} " f"arrived after reap; server may have already executed " f"tool={req.tool_name}" ) req.state = RequestState.RESOLVED def dispatch(t: MultiplexedTransport, req: InFlightRequest) -> None: if t.dead: raise TransportReapError( f"conn={t.conn_id} dispatch on dead transport req={req.request_id}" ) t.in_flight[req.request_id] = req # Trigger trace: slow search call holds the read loop, fast code call # resolves server-side but its frame is behind the slow response. t = MultiplexedTransport(conn_id=7) dispatch(t, InFlightRequest("search", 41, "search.query", idempotent=True)) dispatch(t, InFlightRequest("code", 42, "code.execute", idempotent=False)) # Idle-read deadline fires on the slow search call; reaper runs. # The non-idempotent code.execute is still IN_FLIGHT -> raises, preventing # the duplicate execution that the naive retry policy would cause. try: t.reap() except TransportReapError as e: # Correct behavior: planner sees a hard failure for req=42, not a # retryable transport error, and does not re-execute the script. print(f"guardrail fired: {e}") ```