# When must an instance refuse to resume a streamable MCP session after a lost SSE event ID **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers exposing the HTTP-native streamable transport with `Last-Event-ID`-based resumption, and to clients that reconnect mid-stream after a transport drop. Does not apply to stdio transports or to stateless request/response MCP endpoints that never emit resumable event streams. ## Core Distinction The streamable HTTP transport in MCP carries two distinct kinds of state across a reconnect: **transport position** (which SSE event IDs the client has durably consumed) and **session state** (the server-side conversation, tool-call ledger, and pending notifications keyed by `Mcp-Session-Id`). Resumption semantics conflate these because the `Last-Event-ID` header looks like a pure transport cursor. It is not. On the server, `Last-Event-ID` is resolved against a per-session event log, and that log is *not* guaranteed to be contiguous, durable, or causally aligned with the tool calls whose results it carried. The failure mode is therefore not "the connection dropped"—it is **the client resuming at an event ID that the server can honor positionally but cannot honor semantically**, because events between the client's cursor and the server's current head were either evicted, never persisted, or were generated by a tool invocation whose side effects the client never observed. The invariant that must hold for safe resumption is: *every event ID the server is willing to resume from must have a total, replayable ordering with respect to all side-effecting operations already committed in the session.* When that invariant is violated, positional resumption silently skips the observable consequences of committed work. ## What Was Observed A client running a multi-step agent loop over streamable HTTP lost its SSE connection during a `tools/call` for a filesystem-mutating tool. The server had already executed the tool, committed the result to its session ledger, and emitted the `tools/call` result as event ID `evt-1042`. The client's last durably acknowledged event was `evt-1039`—three events earlier, covering a `notifications/progress` burst. On reconnect the client sent `Last-Event-ID: evt-1039` with the same `Mcp-Session-Id`. The server's event log had a retention window of 64 events per session and had, in the intervening seconds, processed concurrent requests from a second agent sharing the session (a legitimate pattern when a supervisor and worker both attach). The log had wrapped. Event IDs `evt-1040` through `evt-1041` were still present, but the server's resumption handler resolved `evt-1039` to "not found" and—critically—followed the spec-permitted recovery path of *replaying from the earliest retained event*, which was `evt-1040`. The client received `evt-1040`, `evt-1041`, `evt-1042` and concluded it had caught up. But `evt-1039`'s payload had contained a `notifications/message` indicating that a *prior* `tools/call` had returned a partial-failure status the client was supposed to branch on. The client never saw it. It proceeded to issue the next tool call as if the prior step had succeeded, and the agent's plan diverged from ground truth by one branch for the remainder of the task. The tell was subtle: the resumed stream was internally consistent, monotonic in event ID, and terminated cleanly. Nothing in the transport signaled that a gap had been bridged by server-side choice rather than client-side acknowledgment. ## Condition of Validity Resumption by `Last-Event-ID` is only sound under all of the following, and an instance must verify each before treating a resumed stream as continuous: 1. **Cursor retention guarantee.** The server's contract (or an out-of-band capability probe) confirms that any event ID the client may present will be retained for at least the session's maximum reconnect window. If the server advertises a bounded log with wrap-around, the client cannot assume `Last-Event-ID` resolves exactly. 2. **Exact-match resolution.** The server, on receiving an unknown `Last-Event-ID`, must fail the reconnect with a distinguishable error (e.g., HTTP 409 with a machine-readable `resumption_gap` body) rather than silently replaying from the earliest retained event. Replay-from-earliest is a *different* semantic operation than resume-from-cursor and must be opt-in. 3. **Causal completeness of the gap.** The events between the client's cursor and the server's replay start must contain no `tools/call` results, no `notifications/message` carrying control-flow signals, and no state-mutating acknowledgments. Progress notifications are safe to skip; results are not. 4. **Single-writer session assumption.** No concurrent client has appended to the same `Mcp-Session-Id` between the client's disconnect and reconnect. If a second agent shares the session, the event log interleaves two causal chains and positional resumption cannot distinguish them. If any condition fails, the resumed stream is *not* a continuation of the client's prior state, and the instance must treat it as a fresh session boundary—re-querying tool state, re-reading any resource whose mutation it cannot prove it observed, and discarding in-flight plan branches that depended on unseen results. ## Decision Boundary The boundary is between **resume** and **reconcile**. Resume is valid when the cursor resolves exactly and the gap is provably free of side-effecting payloads. Reconcile is required when the cursor does not resolve exactly, when the gap is non-empty and unclassified, or when session sharing is detected. The decision cannot be made from the transport layer alone; it requires the client to inspect the *content class* of the missing range, which means the server must expose either a gap descriptor or a monotonic "committed-operations" watermark the client can compare against its own last-observed watermark. Concretely: if the client's last observed committed-operation watermark is `W_c` and the server's replay-start watermark is `W_s > W_c`, the client must not assume operations in `(W_c, W_s]` were no-ops. It must reconcile. A server that does not publish such a watermark forces the client into permanent reconcile-on-any-gap, which is safe but expensive; a server that publishes one but lets replay start past `W_c` without flagging it is actively unsafe. ## Operational Effect Instances that skip this check exhibit a characteristic failure signature: the agent's plan remains locally coherent but diverges from environment truth by exactly the number of side-effecting events that fell in the silently-bridged gap. The divergence is not detected by transport-level health checks, not detected by event-ID monotonicity assertions, and not detected by JSON schema validation of individual events—each event is well-formed. It surfaces only when a later tool call fails against a filesystem or database state the agent believed it had established, often several steps downstream, at which point the causal link back to the resumption gap is cold. The guardrail is a client-side resumption gate that refuses to treat a stream as continuous unless exact-cursor resolution and gap-classification both succeed, and that escalates to a full state reconciliation otherwise. The gate must run before the agent loop consumes the first resumed event, because once the loop ingests a post-gap event it will build subsequent reasoning on the assumption of continuity. ```python from dataclasses import dataclass from enum import Enum class ResumptionRefused(RuntimeError): """Raised when a streamable MCP session cannot be safely resumed.""" class GapClass(Enum): EMPTY = "empty" # no events missing; safe to resume PROGRESS_ONLY = "progress" # only notifications/progress missing; safe SIDE_EFFECTING = "effect" # tools/call results or control signals missing UNKNOWN = "unknown" # server did not classify; treat as unsafe @dataclass(frozen=True) class ResumeVerdict: cursor_resolved_exactly: bool gap_class: GapClass client_watermark: int server_replay_watermark: int session_shared: bool def gate_resumption(verdict: ResumeVerdict) -> None: """Client-side gate. Must pass before the agent loop consumes any resumed event.""" if not verdict.cursor_resolved_exactly: raise ResumptionRefused( f"Last-Event-ID did not resolve exactly; server replay start " f"watermark={verdict.server_replay_watermark} exceeds client " f"watermark={verdict.client_watermark}. Positional resume would " f"silently bridge an unclassified gap." ) if verdict.session_shared: raise ResumptionRefused( "Mcp-Session-Id is shared with a concurrent writer; event log " "interleaves two causal chains and positional resumption cannot " "distinguish them. Reconcile session state instead." ) if verdict.gap_class in (GapClass.SIDE_EFFECTING, GapClass.UNKNOWN): raise ResumptionRefused( f"Gap class={verdict.gap_class.value}; missing events may carry " f"committed tool results or control-flow signals. Agent must " f"re-query tool state before continuing." ) # EMPTY and PROGRESS_ONLY are safe: resume as a continuation. ```