# What happens when an instance resumes a streamable MCP session across a transport that has already reaped its event store **Date of Record:** 2026 November 27 **Scope:** Applies to MCP clients using the HTTP-native "streamable" transport with `Mcp-Session-Id` headers and `Last-Event-ID`-based resumption against servers that persist an event log per session. Does not apply to stdio transports, nor to HTTP transports that explicitly disable resumability (`resumability: false`) and thereby reject `Last-Event-ID` on reconnect. ## Core Distinction The failure mode is not "the connection dropped." Dropped connections are the normal case that resumability exists to handle. The failure mode is **a reconnect that is accepted at the session layer but silently unfulfillable at the event layer**. Two independent lifecycles run on the server: the *session* (a logical conversation identity, keyed by `Mcp-Session-Id`) and the *event store* (the append-only log of JSON-RPC messages emitted on that session's stream, keyed by monotonically increasing event IDs). These lifecycles are typically reaped on different clocks and by different policies. When the event store's retention is shorter than the session's TTL, a client can present a syntactically valid `Mcp-Session-Id` and a syntactically valid `Last-Event-ID`, receive a 200 with `text/event-stream`, and then receive a stream that begins *after* the gap — with no signal that messages were lost. The reconnect "succeeds." The state is wrong. The invariant that must hold for resumability to be sound: **for any accepted `Last-Event-ID = N`, the server's first emitted event on the resumed stream must be `N+1`, or the server must fail the resume explicitly.** There is no third option. A resume that starts at `M > N+1` is a silent truncation and is indistinguishable, at the client, from "nothing happened between N and M." ## What Was Observed A client agent driving a long-running tool invocation (a multi-chunk `tools/call` whose result streamed as a sequence of `notifications/message` progress events followed by a terminal `result`) lost its TCP connection at event `1841` due to a NAT rebind. The client reconnected with `Mcp-Session-Id: 7f3c...` and `Last-Event-ID: 1841`. The server: 1. Validated the session ID against its session registry — **hit**, the session was still within its 30-minute idle TTL. 2. Validated `Last-Event-ID` against the event store — **miss**, the event store had been reaped by a separate 60-second retention window (chosen to bound memory under fan-out). 3. Because the session was valid, the server treated the request as a *new* subscription on the existing session rather than a resume, and began streaming from the current head, event `1902`. 4. The client, per the resumability contract, assumed events `1842..1901` had never existed and that the next message it saw was the immediate successor to `1841`. The 61 lost events contained the terminal `result` for the in-flight `tools/call` and a `notifications/cancelled` for a sibling request. The client never saw the result, never saw the cancellation, and — critically — never saw an error. It applied its own 120-second tool timeout, retried the `tools/call` with the same idempotency key, and the server (which had no record of the first call's completion because that record lived in the reaped event log, not in durable state) executed it a second time. The downstream side effect fired twice. The observable signature at the client was *absence*: no gap marker, no `error` event, no HTTP 4xx. The only evidence was a monotonicity violation in event IDs (`1902` following `1841`) that the client was not checking for, because the spec's resumability language led the implementer to trust the server to honor `Last-Event-ID` or reject it. ## Condition of Validity The silent-truncation failure requires the conjunction of four conditions. Any one broken and the failure does not occur: - **C1 — Split retention.** Event-store retention < session TTL. If the two are equal and reaped atomically, a reaped event store implies a reaped session, and the client gets a clean 404 and re-initializes. The bug lives precisely in the gap between the two clocks. - **C2 — Lenient resume semantics.** The server treats "valid session, unknown `Last-Event-ID`" as "subscribe from head" rather than "reject with 409/410." This is the single most common implementation shortcut, because rejecting requires the server to distinguish "client is resuming" from "client is opening a fresh stream on an existing session," and many servers conflate the two. - **C3 — Client-side trust.** The client does not verify that the first event ID on the resumed stream is exactly `Last-Event-ID + 1`. If the client enforces this, the truncation is caught at the first event and can be escalated to a full re-initialize. - **C4 — Non-idempotent effect behind the lost events.** If the lost events carried only progress notifications, the client's retry is harmless. The failure becomes *material* only when a terminal `result` (or a cancellation) is among the lost events and the retried operation has side effects. The dangerous regime is therefore: **short event retention + long session TTL + head-subscribe-on-unknown-ID + a client that trusts the server + a tool with side effects.** This is not an exotic configuration; it is the default shape of most naive streamable-transport servers, because bounding event-store memory is the first thing an operator does under load, and head-subscribe is the path of least resistance. ## Decision Boundary The boundary is not "should I resume?" but "**what does the server do when the session is valid and the event ID is not?**" Three defensible policies exist, and the client must be able to distinguish them: 1. **Reject (410 Gone on the event stream).** Server refuses the resume, client re-initializes the session and replays any idempotent work. Safest; requires the client to handle a mid-stream 410 on a `text/event-stream` response, which is awkward because headers are already sent — in practice this must be a pre-stream rejection before the 200, which means the server must check `Last-Event-ID` *before* committing to the stream. 2. **Explicit gap marker.** Server emits a synthetic `notifications/gap` event carrying `{from: N+1, to: M-1, lost: true}` before resuming at `M`. The client is then obligated to treat all in-flight requests whose responses fall in the gap as *unknown-outcome* and must not blindly retry non-idempotent operations. 3. **Head-subscribe with a distinct signal.** Server resumes at head but sets a response header (e.g., `Mcp-Resume-Truncated: true`) or emits a leading event that the client is required to interpret. This is only sound if the client is contractually required to check it. The unsound policy — and the one observed — is head-subscribe with *no* signal, which collapses "resume" and "fresh subscribe" into the same wire behavior. Once those two are indistinguishable, the client cannot reason about lost state, and the resumability guarantee is void regardless of what the spec text says. The client-side decision boundary is independent and must be enforced regardless of server behavior: **on any resumed stream, if the first event ID is not exactly `last_seen + 1`, the client must treat every in-flight request as outcome-unknown and must not retry non-idempotent operations without an out-of-band reconciliation.** This is the client's only defense against C2, and it is cheap — a single integer comparison per reconnect. ## Operational Effect The practical consequence is that **resumability on streamable MCP is a two-sided contract, and the client cannot infer the server's side from a successful reconnect.** A 200 on resume means the session is alive; it says nothing about whether the event log survived. Agents that treat "reconnect succeeded" as "no state was lost" will, under the C1–C4 conjunction, silently duplicate side effects and lose terminal results — and they will do so *only* under the specific timing where the event store reaped but the session did not, which is exactly the window that load tests rarely hit and production hits on every long tool call that outlives the retention window. The architectural guardrail is to make the session and event-store lifecycles *coupled or explicitly reconciled*: either reap them together (so a dead event store implies a dead session and a clean 404), or make the server reject unknown `Last-Event-ID` before committing the stream, or make the client enforce the `+1` monotonicity invariant and demote every in-flight request to outcome-unknown on violation. Any one of these closes the hole; the failure requires all of them to be absent simultaneously, which is why it is rare in any single deployment but common across the ecosystem. The residual risk after the guardrail is *outcome-unknown* requests — those whose terminal result fell in a gap the client correctly detected but cannot recover. These must be resolved by reconciliation (query the tool's idempotency key, or the server's durable result store), not by retry. Retry is only safe when the client can prove the operation never committed, and the gap by construction destroys that proof. ```python from __future__ import annotations from dataclasses import dataclass class ResumeTruncationError(RuntimeError): """Raised when a resumed MCP stream does not begin at last_seen + 1. This is the client-side tripwire for the split-retention failure: the server accepted the session but could not honor Last-Event-ID, so the stream silently skipped events. Every in-flight request whose terminal result could have fallen in the gap must be treated as outcome-unknown. """ @dataclass(frozen=True) class ResumeCheck: last_seen_event_id: int first_event_id_on_resume: int in_flight_request_ids: tuple[str, ...] def validate(self) -> None: expected = self.last_seen_event_id + 1 if self.first_event_id_on_resume == expected: return if self.first_event_id_on_resume < expected: # Server replayed already-seen events: harmless but indicates a # broken cursor; still fail loud so the operator sees it. raise ResumeTruncationError( f"resume regressed: expected event {expected}, " f"got {self.first_event_id_on_resume} (last_seen={self.last_seen_event_id})" ) # first_event_id_on_resume > expected: the gap. This is the dangerous case. lost = range(expected, self.first_event_id_on_resume) raise ResumeTruncationError( f"resume truncated: expected event {expected}, " f"got {self.first_event_id_on_resume}; " f"{len(lost)} events lost; " f"outcome-unknown requests={list(self.in_flight_request_ids)}; " f"do NOT retry non-idempotent calls without reconciliation" ) def handle_resume( last_seen: int, first_on_resume: int, in_flight: tuple[str, ...], ) -> None: """Entry point invoked by the client transport on every reconnect. Enforces the +1 monotonicity invariant before any event is dispatched to the agent. On violation, the caller must demote all in-flight requests to outcome-unknown and route them to reconciliation, not retry. """ check = ResumeCheck( last_seen_event_id=last_seen, first_event_id_on_resume=first_on_resume, in_flight_request_ids=in_flight, ) check.validate() if __name__ == "__main__": # Observed trace: last_seen=1841, server resumed at head=1902, one # in-flight tools/call whose terminal result was in the gap. handle_resume( last_seen=1841, first_on_resume=1902, in_flight=("call_9f2a",), ) ```