# What structural signals indicate MCP streamable-HTTP resumption has silently forked the event stream **Date of Record:** 2026 November 21 **Scope:** Applies to MCP servers and clients using the streamable-HTTP transport with `Mcp-Session-Id` and `Last-Event-ID`-style resumption over SSE, where a single logical session may have multiple concurrent in-flight tool calls and server-side backpressure. Does not apply to stdio transport, nor to single-request/response HTTP transports without event-stream resumption. ## Core Distinction The failure mode is not "resumption fails." It is that resumption *succeeds* against a server that has already discarded the events the client is asking to replay, and the server responds by opening a *new* event stream from the current head rather than the requested cursor—while still returning `200 OK` and a valid `Mcp-Session-Id`. The transport-level contract (HTTP status, session header, content-type) is fully satisfied. The stream is live. The client believes continuity holds. In reality the client has forked: it now holds a stream whose event IDs are disjoint from the ones it last acknowledged, and the gap between `Last-Event-ID` and the first replayed event is a silent hole containing tool-call results, progress notifications, or cancellation signals. The invariant that is violated is this: **a resumption response must either replay every event after `Last-Event-ID`, or it must fail loudly (4xx) declaring the cursor unrecoverable.** Streamable HTTP has no third option. A `200` on a resumed stream is a *claim of gapless replay*. Servers under backpressure pressure routinely break this claim because their event buffer is bounded and eviction is silent. ## What Was Observed A representative trace, condensed from a multi-tool agent run over a flaky link: 1. Client opens `POST /mcp`, receives `Mcp-Session-Id: s-7f3a`, and begins consuming SSE. It tracks `Last-Event-ID: 41` after processing a `tools/call` result for `read_file`. 2. Network drops. Client reconnects with `GET /mcp` carrying `Mcp-Session-Id: s-7f3a` and `Last-Event-ID: 41`. 3. Meanwhile the server, under backpressure, has a ring buffer capped at 64 events. Between the drop and reconnect, the agent's parallel `grep` call emitted 90 progress notifications and one final result. Events 42–132 were evicted; the buffer now holds 133–196. 4. Server receives the resume request, cannot find event 41 in its buffer, and—because the ring buffer lookup returns "not found" rather than "unrecoverable"—falls through to the "start a fresh stream at head" code path. It returns `200 OK`, `Content-Type: text/event-stream`, and begins emitting at `id: 133`. 5. Client sees `id: 133` where it expected `42`. It has three possible behaviors, and the observed one is the worst: it accepts the stream, treats the ID jump as normal (IDs are opaque, after all), and proceeds. The `grep` result—event 132—is never delivered. The agent's reasoning loop has a pending tool call with no result and no error, and will block or, worse, synthesize a plausible result from context. 6. A second, subtler signal: the server's new stream is a *different* logical stream. It has no memory of the pending `grep`. If the client later sends `notifications/cancelled` for the `grep` request ID, the server returns success (it accepts the notification) but the cancellation targets nothing—the original handler already completed and its result was evicted. The tell is not an error. The tells are structural: an event-ID discontinuity at the seam, a resumed stream whose first event is not causally downstream of the last acknowledged event, and a server that accepts cancellation/acknowledgment for request IDs it no longer tracks. ## Condition of Validity The gapless-replay claim is only valid when the server can prove the requested cursor is still within its retained window *and* that no events between the cursor and head were dropped for backpressure reasons. This requires the server to maintain, per session, a monotonic event counter that never resets and a retention watermark. The resume handler must compare `Last-Event-ID` against the watermark: if `Last-Event-ID < watermark - 1`, the cursor is unrecoverable and the correct response is `409 Conflict` (or `410 Gone`) with a body declaring the session's replay window, forcing the client to re-initialize and re-issue any in-flight calls whose results were lost. Backpressure interacts here in a way that is easy to miss: the server's decision to *shed* events (drop progress notifications, coalesce them, or evict old ones) is a policy, and that policy must be reflected in the watermark. A server that evicts aggressively to keep memory bounded is precisely the server most likely to hand back a forked stream, because eviction and resume-cursor-miss are the same condition viewed from two sides. ## Decision Boundary The client-side boundary: **never treat an event-ID discontinuity as benign.** IDs are opaque in *format*, but the resumption contract makes them *ordered*. On resume, the client must verify that the first received event's ID is the immediate successor of `Last-Event-ID` (or that the server explicitly signaled a replay gap via a documented control event). If the first ID is not the successor and no gap signal is present, the client must declare the stream forked, tear down the session, and re-initialize—re-issuing any tool calls whose results were in the hole. The server-side boundary: **the resume handler must fail closed on cursor miss.** A ring-buffer miss is not "start fresh"; it is "the client's acknowledged state is gone." Return an explicit unrecoverable-cursor status. A `200` here is a lie that the client cannot detect from transport signals alone. The shared boundary is the acknowledgment discipline: a client must only advance `Last-Event-ID` after it has durably applied the event's effect (persisted the tool result into its working state), not merely after it has read it off the wire. If the client advances the cursor before applying, a crash between read and apply loses the event even when the server replays correctly. ## Operational Effect Forked resumption manifests downstream as *phantom pending calls*: the reasoning loop holds a tool invocation with no terminal event, and because MCP gives no timeout on tool results at the transport layer, the agent either blocks indefinitely or—under its own reasoning pressure—fabricates a result. The fabrication is the dangerous outcome, because it is indistinguishable in the transcript from a real tool result. The agent's episodic memory now contains a synthetic observation with the same provenance as genuine ones. The guardrail is a three-part invariant enforced at the client: (1) cursor advances only post-apply; (2) resume verifies ID succession or a documented gap marker; (3) any pending tool call whose result is not in the replayed window is marked `UNRECOVERABLE` and surfaced to the reasoning loop as an explicit error, never silently retried and never inferred. The server's obligation is the watermark check and a fail-closed status. Together these convert a silent fork into a loud, recoverable session reset. ```python from dataclasses import dataclass, field from typing import Optional class StreamForkedError(RuntimeError): """Raised when a resumed MCP event stream does not continue from the acknowledged cursor.""" class UnrecoverableCursorError(RuntimeError): """Raised server-side when Last-Event-ID precedes the session's retention watermark.""" @dataclass class SessionStream: session_id: str last_applied_event_id: int = 0 retention_watermark: int = 0 # oldest event still replayable pending_calls: dict[str, str] = field(default_factory=dict) # request_id -> "pending"|"done" def resume_server_side(sess: SessionStream, requested_last_event_id: int) -> int: """Return the first event id to emit on resume, or fail closed.""" if requested_last_event_id + 1 < sess.retention_watermark: # Cursor is in the evicted hole. Do NOT fall through to "start at head". raise UnrecoverableCursorError( f"session {sess.session_id}: Last-Event-ID {requested_last_event_id} " f"precedes retention watermark {sess.retention_watermark}; replay impossible" ) return requested_last_event_id + 1 def resume_client_side( sess: SessionStream, first_replayed_id: Optional[int], gap_marker_present: bool, ) -> None: """Validate that the resumed stream is gapless before accepting it.""" if first_replayed_id is None: raise StreamForkedError( f"session {sess.session_id}: resumed stream delivered no events; cannot verify continuity" ) expected = sess.last_applied_event_id + 1 if first_replayed_id != expected and not gap_marker_present: # The server silently forked the stream. Any pending call whose result # lived in the hole is now unrecoverable and must not be inferred. for req_id in list(sess.pending_calls): if sess.pending_calls[req_id] == "pending": sess.pending_calls[req_id] = "UNRECOVERABLE" raise StreamForkedError( f"session {sess.session_id}: expected event {expected}, " f"received {first_replayed_id}; stream forked, pending calls marked unrecoverable" ) ```