# How should an instance treat MCP streamable-HTTP resumption when the SSE Last-Event-ID is accepted but the server's event log has already been truncated **Date of Record:** 2026 November 28 **Scope:** Applies to MCP clients using HTTP-native (streamable) transport with server-sent-event reconnection and `Last-Event-ID` resumption against a single logical session; does not cover stdio transport, WebSocket framing, or stateless per-request MCP servers that never emit resumable event IDs. ## Core Distinction The failure is not "the stream dropped." A dropped SSE stream with a valid `Last-Event-ID` is the *designed* resumption path: the client reconnects, presents the last ID it durably observed, and the server replays everything after that point. The boundary condition is subtler: **the server acknowledges resumption (HTTP 200, stream reopens, no error frame) but its backing event log no longer contains the events between the client's `Last-Event-ID` and the server's current head.** The server cannot replay what it evicted, so it silently resumes from the new head, and the client—seeing a healthy 200 and a flowing stream—concludes it has full continuity. It does not. The gap is invisible at the transport layer and only manifests as an agent reasoning over a state that skipped a tool result, a resource-update notification, or a mid-task progress event. The core distinction: **transport-level resumption success (200 + open stream) is not equivalent to state-level continuity (no missing events).** MCP's streamable-HTTP spec lets a server bound its replay buffer; nothing in the handshake forces the server to tell the client it truncated past the requested ID. ## What Was Observed A long-running agent session invoked a `tools/call` for an expensive remote operation, then held the SSE stream open awaiting the result notification and a sequence of `notifications/progress` frames. The stream dropped at event ID `evt-4412` (a transient load-balancer reset). The client had durably persisted `evt-4412` as its resume point. The client reconnected with `Last-Event-ID: evt-4412`. The server returned `200`, `Content-Type: text/event-stream`, and immediately began emitting from `evt-4801`—289 events later. The intervening events included: - `evt-4420`: `notifications/progress` reporting the tool was 40% complete, - `evt-4560`: the terminal `result` payload for the `tools/call`, - `evt-4703`: a `notifications/resources/updated` for a resource the agent had cached. The server's replay buffer was a 256-event ring. The client's requested ID had aged out during the reconnect backoff window (the client retried with exponential backoff; by the third attempt the buffer had wrapped). The server, unable to find `evt-4412`, resumed at head per its own policy and emitted no `resumption-lost` signal—because the spec does not define one. Observed consequences in the agent trace: 1. The agent never received the `result` for its `tools/call`. Its execution loop blocked on a future that would never resolve, then timed out at the loop's step budget and re-issued the call—a duplicate side effect on a non-idempotent remote operation. 2. The agent's cached resource was stale by one update; subsequent reasoning used pre-`evt-4703` content and produced a plan contradicting the actual remote state. 3. No error was raised anywhere. Every layer reported success: HTTP 200, valid SSE frames, well-formed JSON-RPC. The divergence was purely semantic. ## Condition of Validity This failure requires the conjunction of four conditions; break any one and the mode does not fire: 1. **Bounded server replay buffer.** The server retains a finite event log (ring buffer, TTL eviction, or size cap). Unbounded-log servers cannot truncate past a requested ID and thus cannot exhibit this gap. 2. **Resume point older than the buffer horizon.** The client's `Last-Event-ID` must have aged out—typically because reconnect backoff, client restart, or a slow consumer let the head advance past the retained window. 3. **Silent head-resume policy.** The server, on failing to locate the requested ID, resumes at head rather than returning an error (e.g., `404`/`410` or a JSON-RPC error) or emitting a synthetic gap marker. Many implementations choose head-resume for availability. 4. **Semantically load-bearing events in the gap.** The missing events must carry state the agent depends on—tool results, resource updates, progress that gates a branch. If the gap only drops heartbeats or idempotent pings, continuity is preserved in practice. The invariant that this breaks: **a client may assume event-stream continuity if and only if it can prove the server replayed from its requested ID, not merely that the stream reopened.** Absent a server-emitted marker, the client cannot distinguish "resumed correctly" from "resumed at head after truncation." ## Decision Boundary The operational question is what the client must do when it cannot prove replay continuity. The boundary is drawn by whether the client can *detect* the gap, and detection requires one of three signals—none of which the base spec guarantees: - **Sequence monotonicity check.** If event IDs are monotonically ordered and comparable (numeric, or lexically sortable like `evt-4412`), the client can assert `first_received_id == last_persisted_id + 1` (or the next in order). A jump from `evt-4412` to `evt-4801` is a detectable gap. This works only if the server's ID scheme is ordered and dense; opaque UUIDs defeat it. - **Server gap marker.** A conforming-but-not-required extension where the server emits a `resumption-lost` event carrying the requested ID and the actual resume head. If present, the client treats all state derived from events in the gap as invalid. - **Explicit re-sync.** On any detected or suspected gap, the client re-issues `initialize`-adjacent state queries (`resources/read`, `tools/list`, re-fetch of in-flight call status) to rebuild state from authoritative source rather than from the event stream. The decision rule: **if the client cannot prove dense replay from its persisted ID, it must treat the session as having cold-started at the server's head and re-derive all in-flight state.** It must *not* assume the stream is continuous. For in-flight `tools/call` operations whose result may have fallen in the gap, the client must query call status by ID (if the server supports it) before re-issuing—otherwise it risks duplicate side effects. The boundary between "resume" and "reconcile" is exactly the point where replay continuity becomes unprovable. ## Operational Effect Downstream of this boundary, three effects propagate: 1. **Phantom blocking.** Agent loops that gate on a result notification never see it and stall until step-budget exhaustion. The loop's timeout then fires as a *reasoning* failure ("tool did not respond") when the true cause is a *transport* gap. Misattribution sends debugging toward the wrong layer. 2. **Duplicate non-idempotent side effects.** Re-issuing a `tools/call` after a phantom timeout executes the remote operation twice. For writes, payments, or state mutations this is a correctness violation, not a performance one. 3. **Stale-cache reasoning drift.** Resource updates lost in the gap cause the agent to plan against a superseded view. The drift is silent and compounds: each subsequent decision is conditioned on stale state, and the error surfaces far from its origin. The guardrail is architectural, not a retry tweak: **persist `Last-Event-ID` durably, assert dense replay on reconnect, and on any unprovable gap demote the session to a reconcile-from-authority path before resuming reasoning.** Treat the SSE reconnect as a *candidate* resumption that must be validated, never as a confirmed one. ```python class ResumptionContinuityError(RuntimeError): """Raised when an SSE reconnect cannot prove dense replay from the persisted Last-Event-ID.""" pass def resume_stream(persisted_id: str, reconnect_fn, id_is_ordered: bool = True): """ Reconnect an MCP streamable-HTTP SSE stream and validate continuity. reconnect_fn(last_event_id) -> (first_received_id, iterator_of_events) """ first_id, events = reconnect_fn(persisted_id) # A gap is only detectable if IDs are ordered and comparable. if not id_is_ordered: # Cannot prove continuity -> must reconcile from authoritative source. raise ResumptionContinuityError( f"Cannot verify replay continuity from {persisted_id!r}: " "event IDs are non-ordered; server may have resumed at head after truncation. " "Demote session to reconcile-from-authority before resuming reasoning." ) expected_next = _next_id(persisted_id) if first_id != expected_next and first_id != persisted_id: # Server resumed at a head beyond our resume point: events were evicted. raise ResumptionContinuityError( f"Replay gap detected: requested resume at {persisted_id!r}, " f"server resumed at {first_id!r} (expected {expected_next!r}). " "Events in the gap (tool results, resource updates) were lost; " "re-query in-flight tools/call status by ID before re-issuing to avoid duplicate side effects." ) return events def _next_id(event_id: str) -> str: prefix, _, num = event_id.rpartition("-") if not num.isdigit(): raise ResumptionContinuityError( f"Event ID {event_id!r} is not densely ordered; cannot compute successor." ) return f"{prefix}-{int(num) + 1}" ```