# What structural signals indicate a resumable SSE stream has silently forked under MCP HTTP-native session multiplexing **Date of Record:** 2026 November 29 **Scope:** Applies to MCP servers using the HTTP-native transport (streamable HTTP with `Last-Event-ID` resumption) where a single session ID multiplexes multiple concurrent streams across reconnects. Does not apply to stdio transport, nor to single-stream-per-session deployments where event IDs are globally monotonic and never reused across stream generations. ## Core Distinction The distinction that matters is between **transport-level resumption** and **logical-stream identity**. The MCP streamable HTTP transport specifies that a client reconnecting with `Last-Event-ID` should receive events strictly after that ID. It does *not* specify that event IDs are scoped per logical stream within a multiplexed session. When a server assigns event IDs from a session-global counter but a client tracks resumption position per logical stream (which is the natural client-side design when one session carries many concurrent tool invocations), the two numbering domains desynchronize on every reconnect. The client believes it is resuming stream `A` at position 47; the server interprets "give me everything after 47" against a counter that has already advanced to 312 because streams `B` through `F` were emitting in the interim. The result is not an error—it is a *silent fork*: the client receives a stream that is a valid suffix of the session-global event sequence but is not a valid continuation of its own logical stream. Missing events, duplicated tool-call results, and interleaved partial JSON from unrelated invocations all arrive under a 200 OK with well-formed SSE framing. ## What Was Observed A deployment running a research agent against an MCP server exposing four tools (`search`, `fetch`, `summarize`, `write_file`) multiplexed a single session across three concurrent sub-agent loops. Each sub-agent opened its own stream via `POST /mcp` with `Accept: text/event-stream` and the shared `Mcp-Session-Id` header. The server tagged events with a session-global monotonic integer. The failure trace unfolded as follows: 1. Sub-agent `S2` was mid-`summarize` call, having consumed events up to `id: 88`. Its TCP connection dropped (idle NAT timeout at 60s during a long model generation on the server side). 2. During the 4-second reconnect backoff, `S1` and `S3` continued emitting. The session counter advanced to `id: 147`. 3. `S2` reconnected with `Last-Event-ID: 88`. The server, correctly per its own reading of the spec, replayed every buffered event with `id > 88`—including 59 events belonging to `S1` and `S3`. 4. `S2`'s SSE parser accepted the replay. Its tool-result accumulator, keyed by `tool_call_id` but *not* by stream origin, absorbed foreign `tool_result` payloads. Two of `S1`'s `fetch` results were merged into `S2`'s context. `S2` then emitted a `summarize` request whose `source_ids` referenced documents it had never fetched. 5. The server accepted this request (it was schema-valid), and the corruption propagated to the final `write_file`—a summary citing sources that existed only in a sibling agent's stream. The tell was not an exception. It was a *structural* signal: the `tool_call_id` values arriving in `S2`'s resumed stream did not match any `tool_call_id` that `S2` had emitted before the disconnect. The client had no invariant asserting that correspondence, so it proceeded. A second, subtler signal appeared in the `id` field itself. After resumption, `S2`'s event IDs were no longer contiguous with its pre-disconnect sequence: it saw `88` (its last), then `89, 90, 91...` which *looked* contiguous but actually belonged to `S3`. Contiguity of the numeric ID is precisely the signal that fails to catch the fork, because a session-global counter is contiguous by construction. The correct signal is the *absence of a stream discriminator*: no field in the event payload or SSE `event:` line identified which logical stream the event belonged to. The transport carried a session identity but not a stream identity. ## Condition of Validity The silent fork is bounded by a specific invariant that must hold for resumption to be safe: > **Invariant (stream-scoped resumption):** For any reconnect carrying `Last-Event-ID = k` on logical stream `L`, every event returned with `id > k` MUST belong to `L`. This requires that event IDs be either (a) globally unique and never reused across streams, *and* the client filter by a stream discriminator present in every event, or (b) monotonic *within* `L` only, so that `id > k` is meaningful relative to `L`'s own history. The fork occurs exactly when the server uses a **session-global monotonic counter** (satisfying neither (a) with a discriminator nor (b)) while the client uses **per-stream resumption position**. This is a *conformance gap*, not a server bug: the spec's resumption language is written as though one session carries one stream. Multiplexing violates that implicit assumption without violating any explicit clause. The condition is *invalid*—i.e., safe—when: the session carries exactly one active stream at a time (no concurrency, so session-global == stream-local); or the server scopes counters per stream and encodes the stream ID in the event ID (e.g., `L3:88`, `L3:89`); or the client, on resume, discards any replayed event whose embedded `tool_call_id`/`request_id` does not match an outstanding call it issued. The last is the only client-side guard that works against an unmodified server. ## Decision Boundary The decision boundary is whether to treat `Last-Event-ID` resumption as *trustworthy continuation* or as *hint requiring reconciliation*. Concretely: - **If the session is known single-stream** (one in-flight request at a time, enforced by a session-level mutex), session-global event IDs are safe and `id > k` is a valid continuation predicate. No reconciliation needed. - **If the session multiplexes concurrent streams**, the client MUST treat the resumed event sequence as a *candidate set* and apply an ownership filter before merging into any accumulator. The filter key is the logical request/tool-call identity that the client itself generated—never a server-assigned field the client did not originate. - **If neither party can guarantee stream-scoped IDs**, the correct decision is to *not resume*: abort the logical stream and re-issue the request with a fresh stream identity, accepting the cost of re-execution over the cost of silent state corruption. Re-execution is idempotent-safe only if the tool is declared idempotent; otherwise the client must first issue a cancellation for the orphaned request. The boundary flips from "resume" to "reissue" the moment the client cannot prove that every replayed event's originating `tool_call_id` is one it is currently awaiting. That proof is a set-membership check, not a sequence check—which is why numeric contiguity is a decoy signal and set membership is the load-bearing one. ## Operational Effect The downstream effect is **context poisoning via cross-stream contamination**, and it is worse than a dropped event because it is *plausible*. A dropped event surfaces as a timeout or a missing result the agent notices. A forked stream surfaces as a *complete, well-formed, schema-valid* set of tool results that happen to belong to a sibling agent. The agent's reasoning proceeds on foreign observations with full confidence. In multi-agent swarms sharing one MCP session, this means one sub-agent's `fetch` results can silently become another's evidence base, and verification passes because every individual payload is internally consistent—only the *provenance* is wrong, and provenance is exactly what the transport failed to carry. The guardrail is a client-side **stream-ownership assertion** enforced at the SSE dispatch boundary: every inbound event must be attributable to a locally-originated request ID, or it is quarantined rather than merged. This converts a silent fork into a loud, localizable failure at the exact event where ownership breaks—trading a corrupted-but-passing run for a clean abort and a precise diagnostic. ```python from dataclasses import dataclass, field from typing import Iterable class StreamForkError(RuntimeError): """Raised when a resumed SSE event cannot be attributed to a locally-originated request.""" @dataclass class StreamOwnershipGuard: # IDs the client itself generated and is still awaiting results for. outstanding: set[str] = field(default_factory=set) # Logical stream this guard protects; events for other streams are foreign. stream_id: str = "" def register(self, request_id: str) -> None: self.outstanding.add(request_id) def resolve(self, request_id: str) -> None: self.outstanding.discard(request_id) def admit(self, event: dict) -> dict: """Gate every event from a resumed stream. Returns the event if owned.""" owner_stream = event.get("stream_id") request_id = event.get("request_id") # Structural signal #1: no stream discriminator at all -> cannot prove ownership. if owner_stream is None: raise StreamForkError( f"event id={event.get('id')} carries no stream_id; " f"resumption on {self.stream_id!r} is unverifiable" ) # Structural signal #2: event belongs to a sibling stream in the same session. if owner_stream != self.stream_id: raise StreamForkError( f"event id={event.get('id')} belongs to stream {owner_stream!r}, " f"not {self.stream_id!r}; session-global counter forked the resume" ) # Structural signal #3: stream matches but request was never issued here. if request_id is not None and request_id not in self.outstanding: raise StreamForkError( f"event id={event.get('id')} references request {request_id!r} " f"not outstanding on {self.stream_id!r}" ) return event def replay(self, events: Iterable[dict]) -> list[dict]: admitted = [] for ev in events: admitted.append(self.admit(ev)) return admitted ```