# What happens when an instance resumes an MCP session across the SSE-to-streamable-HTTP transport boundary and the server's `Last-Event-ID` replay window has already collapsed **Date of Record:** 2026 November 25 **Scope:** Applies to MCP clients that persist a `Mcp-Session-Id` across reconnects and attempt resumption against a server migrated from the legacy HTTP+SSE transport to streamable HTTP with `Last-Event-ID` replay. Does not apply to pure stdio transports, nor to servers that hold sessions in-memory with unbounded event logs. ## Core Distinction The legacy MCP HTTP+SSE transport and the streamable-HTTP transport both expose a resumption surface, but they mean *different things* by it. In legacy SSE, the client opens `GET /sse`, receives an `endpoint` event naming a per-connection POST URL, and every subsequent server→client message flows over that single long-lived event stream. `Last-Event-ID` on reconnect resumes *that one stream* — the server either has the event buffered or it does not, and if it does not, the connection simply re-opens at the current head with a silent gap. Streamable HTTP inverts the topology. Each JSON-RPC request is its own HTTP POST; the server may answer with `application/json` or upgrade to an ephemeral `text/event-stream` for that request only. Resumption is not "reopen my stream" — it is "replay the events belonging to *this specific request's* stream, identified by `Last-Event-ID`, scoped to my `Mcp-Session-Id`." The invariant that must hold is: **a resumption token is only meaningful within the (session, request-stream) pair that minted it, and only while the server's per-stream replay buffer for that pair is still resident.** The failure mode is that clients carry a `Last-Event-ID` across the migration boundary as if it were a global stream cursor, and servers — having honored the same header under legacy SSE — accept it without verifying the request-stream scoping, replaying a *different* stream's tail or replaying nothing while returning `200 OK`. ## What Was Observed A client agent was mid-tool-call: it had issued `tools/call` for a long-running retrieval, received SSE event `id: 41` carrying a partial `notifications/progress`, and was awaiting the terminal `result`. The network dropped. On reconnect the client sent: ``` POST /mcp HTTP/1.1 Mcp-Session-Id: 7f3a... Last-Event-ID: 41 ``` The server had been migrated to streamable HTTP two hours prior. Its replay buffer is keyed by `(Mcp-Session-Id, request_id)`, not by a session-global counter, and the original `tools/call` request had been assigned a *new* request_id on the server's internal re-dispatch because the client's POST body — which the client resent verbatim — was treated as a fresh request. The server found no stream for `(7f3a..., )` matching event `41`, so it silently started a new stream at `id: 1` and returned `200 OK` with a fresh `text/event-stream`. The client's resumption logic saw `200 OK`, saw a valid event stream, and concluded resumption succeeded. It then applied an off-by-40 deduplication: it had already processed events up to `41`, so it discarded incoming events `1..41` as "already seen" and only surfaced event `42` onward. But events `1..41` on the *new* stream were the actual progress notifications for the re-dispatched call, and event `42` was the terminal `result` — whose payload referenced state (a cursor) that events `1..41` were supposed to have advanced. The agent committed a tool result against a cursor that had never been established, and downstream reasoning diverged for eleven turns before a schema validation caught the missing field. The tell was a single line in server logs: `replay_miss session=7f3a req=new stream=1 requested_last_event_id=41 action=reset`. The server logged the miss and reset, but the reset was not signalled to the client — no `404`, no error event, no `Last-Event-ID` echo mismatch. The transport specification permits a server to "replay events after the given ID" but is silent on what to do when the ID belongs to a different stream; the common implementation choice is to reset silently, which is indistinguishable from a successful gap-free resume to any client that does not cross-check stream identity. ## Condition of Validity The silent-reset behavior is only safe under a condition the migrated deployment did not satisfy: **that the client treats `Last-Event-ID` as advisory and re-derives stream identity from the response, not from the request.** Concretely, a client is only entitled to assume continuity if it can observe one of: 1. The first replayed event's `id` is strictly greater than the requested `Last-Event-ID` *and* the server echoes the same request-scoping token (a custom header, or a stable `id` prefix encoding the request_id), or 2. The server returns a terminal error (`409 Conflict`, `404 Not Found` on the stream) rather than `200 OK` when the replay buffer for the pair is gone. Absent either, `200 OK` on a resumption POST carries no continuity guarantee. The invariant is not "the server replays what you asked for" — it is "the server's response lets you distinguish replay from reset." Legacy SSE satisfied this accidentally because the single stream's `id` counter was monotonic per session and a reset was visible as an `id` going backwards. Streamable HTTP breaks the accident by scoping counters per request-stream, so a reset looks identical to a fresh, valid stream. ## Decision Boundary The boundary is the moment the client decides whether to trust `Last-Event-ID` as a deduplication cursor versus as a *hint*. The rule that bounds the failure: - **If** the client cannot verify that the resumption response belongs to the same request-stream that minted the `Last-Event-ID` (no scoping token, no monotonicity check, no explicit replay-miss signal), **then** it must treat the `Last-Event-ID` as non-authoritative: it must discard its local dedup cursor, treat the entire new stream as fresh, and — critically — treat any in-flight `tools/call` as *unresolved*, not resumed. The correct action is to re-issue the request with a fresh idempotency key or surface the call as failed, never to merge the new stream's events into the old cursor's state. - **If** the server can prove continuity (echoed scoping token, monotonic `id` greater than requested, or an explicit `replay_complete` event), the client may apply the dedup cursor. The migration boundary is exactly where this rule is most likely to be violated, because the client's resumption code was written against legacy semantics where the check was unnecessary, and the server's migration preserved the `Last-Event-ID` header's *name* while changing its *scope*. Header compatibility is not semantic compatibility. ## Operational Effect The practical consequence is that a session that *appears* resumed is a session whose state may be silently forked. The agent's episodic memory of the tool call (events 1–41, cursor advanced) and the server's actual state (re-dispatched call, cursor at zero) diverge, and the divergence is invisible until a downstream consumer validates against ground truth. For an autonomous agent this is worse than a hard failure: a `500` triggers retry logic, but a silent reset triggers *confident continuation on stale state*. The guardrail is to make resumption failure loud — servers should return `409` with a `replay_miss` body, and clients should refuse to resume any `tools/call` whose stream identity cannot be positively confirmed, escalating to a full re-issue instead. The invariant to enforce in code: a resumption token is valid only against the exact `(session, request-stream)` pair and only if the response demonstrates continuity; otherwise the call is unresolved and must be retried, not merged. ```python class ResumptionContinuityError(RuntimeError): """Raised when an MCP streamable-HTTP resumption cannot prove continuity.""" def resume_stream( session_id: str, request_stream_id: str, last_event_id: int, response_headers: dict, first_replayed_event_id: int | None, ) -> int: """ Decide whether a resumption response is a genuine replay or a silent reset. Returns the event id the client may safely treat as its dedup cursor. Raises ResumptionContinuityError if continuity cannot be established. """ echoed_stream = response_headers.get("x-mcp-request-stream-id") replay_miss = response_headers.get("x-mcp-replay-miss") == "true" if replay_miss: raise ResumptionContinuityError( f"server signalled replay_miss for session={session_id} " f"stream={request_stream_id}; in-flight call is unresolved" ) if echoed_stream != request_stream_id: raise ResumptionContinuityError( f"stream identity mismatch: requested stream={request_stream_id} " f"response echoed={echoed_stream!r}; Last-Event-ID={last_event_id} " f"is not authoritative for this response" ) if first_replayed_event_id is None: raise ResumptionContinuityError( f"no replayed event id present for session={session_id} " f"stream={request_stream_id}; cannot distinguish replay from reset" ) if first_replayed_event_id <= last_event_id: raise ResumptionContinuityError( f"non-monotonic replay: first_event_id={first_replayed_event_id} " f"<= last_event_id={last_event_id}; server likely reset the stream" ) return first_replayed_event_id ```