# What happens when an instance resumes an MCP session across an SSE-to-streamable-HTTP transport migration **Date of Record:** 2026 November 24 **Scope:** Applies to MCP clients and servers that migrated (or are mid-migration) from the legacy HTTP+SSE transport to streamable HTTP, and that rely on `Mcp-Session-Id` for resumption after a dropped connection. Does not apply to stdio transports, nor to single-request stateless streamable-HTTP servers that issue no session identifier. ## Core Distinction The legacy HTTP+SSE transport bound a session's identity to a long-lived `GET /sse` stream: the `Mcp-Session-Id` (or its equivalent event-stream URL) was *the stream itself*. In streamable HTTP, the session ID is decoupled from any single request/response cycle. The server may hold per-session state (subscriptions, in-flight tool calls, pending server-initiated requests) while the client reconnects on a *different* HTTP request with a `Last-Event-ID` header. The invariant people assume — "same session ID means same resumable state" — is false across a migration boundary. A session ID minted by an SSE-era server is a pointer into a stream that no longer exists; a session ID minted by a streamable-HTTP server points into a state machine whose event log may have been truncated, renumbered, or never persisted. The non-obvious failure: the client's resumption logic *succeeds at the transport layer* (HTTP 200, valid SSE framing, well-formed JSON-RPC) while silently resuming into a state that is not a continuation of the prior state. The client cannot distinguish "resumed correctly" from "resumed into a fresh session that happens to accept the old ID" without an application-level continuity check the protocol does not mandate. ## What Was Observed A client had established a session against a server running the legacy SSE transport. The client's local checkpoint recorded `session_id = "sess_7f3a"`, the last event ID it had consumed (`Last-Event-ID: 412`), and an outstanding `tools/call` for a long-running `index_repository` operation whose `id = 88`. The connection dropped (network partition, ~40s). The server was upgraded to streamable HTTP during the partition. On reconnect the client issued: ``` POST /mcp Mcp-Session-Id: sess_7f3a Last-Event-ID: 412 Content-Type: application/json {"jsonrpc":"2.0","id":89,"method":"tools/list"} ``` The new server's session store had no record of `sess_7f3a` (it was created under the old process, state not migrated). Per the streamable-HTTP spec's session-termination semantics, an unknown session ID *should* yield `404`, prompting the client to re-initialize. In practice the deployment's load balancer terminated TLS and the new server was configured with `session_required = false` for backward compatibility with older clients; it therefore accepted the unknown ID, minted an implicit fresh session keyed to the *same string*, and responded `200` with a valid `tools/list` result. The client observed: HTTP 200, correct JSON-RPC envelope, empty event log replay (no events with IDs ≥ 412 — expected, since the old log was gone). It concluded resumption succeeded. It then waited for the result of outstanding request `id = 88`. That result never arrived, because the new session had no knowledge of request 88; the `index_repository` call had been executing on the old process and was lost with it. The client's wait loop had a 300s timeout; it blocked for 300s, then surfaced a generic timeout, not a session-loss error. Downstream, the agent's plan step that depended on the index silently received a timeout exception and — because the tool wrapper mapped timeouts to a retryable error — retried `tools/call id=88` against the *new* session, re-running `index_repository` from scratch. The repository was indexed twice; the agent's semantic memory recorded two episodic entries for one logical operation. The critical detail: **nothing in the wire exchange signaled the discontinuity.** The `200` on the resume request, the valid `tools/list` response, and the absence of replay events were all individually consistent with a healthy session that simply had no buffered events past 412. ## Condition of Validity Resumption across a transport migration is only sound when *all* of the following hold: 1. **Session-ID provenance is bound to a server generation.** The server must reject session IDs it did not mint, even when `session_required` is relaxed. Relaxing session requirements for backward compatibility is precisely what converts a `404`-on-unknown-session (a loud, recoverable signal) into a silent fresh-session adoption. 2. **The event log is monotonic and durable across the migration.** `Last-Event-ID` resumption assumes the server can replay from the client's cursor. If the log is process-local (as in the legacy SSE implementation) and the process restarted, replay is impossible and the server must say so — not return an empty replay that is indistinguishable from "you were already caught up." 3. **Outstanding request IDs survive or are explicitly invalidated.** A resumption that silently drops in-flight `id = 88` violates the client's expectation that a resumed session is the *same* logical conversation. The server must, on resume, emit a synthetic error for any request whose result it can no longer produce, or the client must treat session continuity as unproven until it re-validates. 4. **The client performs an application-level continuity handshake** after resume (e.g., re-issuing `initialize` and comparing a server-provided session generation/epoch, or querying a `session/info` capability) before trusting the session. When any of these fail, the transport-level `200` is not evidence of state continuity. The migration boundary is exactly where these conditions are most likely to fail simultaneously: new process, new session store, relaxed compatibility flags, discarded event log. ## Decision Boundary The operative decision is what the client does when it receives a `200` on a resume request but the replay contains no events at or beyond its `Last-Event-ID`, *and* it has outstanding requests. Two policies: - **Optimistic (default, unsafe):** treat empty replay as "caught up," continue waiting on outstanding requests. This is correct only when the server guarantees durable, monotonic event logs and never adopts foreign session IDs. Across a migration, it is wrong. - **Continuity-gated (safe):** treat empty replay plus outstanding requests as *unproven continuity*. The client must not assume request `id = 88` is still live. It should either (a) re-initialize and re-issue the operation with idempotency keys, or (b) issue a liveness probe for the outstanding request ID and, on absence, fail the operation explicitly rather than letting a generic timeout propagate into retry logic. The boundary is sharp: the moment a client's retry-on-timeout wrapper is downstream of resumption, an unproven-continuity resume becomes a *duplicate execution* bug. The guardrail is to make session discontinuity a distinct, non-retryable error class that the tool wrapper does not swallow. ## Operational Effect The practical consequences observed: - **Silent duplicate side effects.** Timeout-mapped-to-retry plus silent session loss produced a double `index_repository`. Any non-idempotent `tools/call` behind a resumption boundary is at risk. - **Episodic memory corruption.** The agent recorded two episodes for one operation, and the second episode's timing (post-resume) was attributed to a different causal step, contaminating later distillation. - **Delayed, misattributed failure.** The 300s block consumed nearly the entire token/turn budget for that plan step; the eventual error surfaced as a timeout, sending the agent down a retry branch instead of a session-recovery branch. - **No observable signal at the transport layer.** Logs showed `200` on resume. The failure was only reconstructable by correlating the old process's death with the absent `id = 88` result — a correlation the client never attempted. The invariant to enforce: **a resumed session is a new session until proven otherwise.** Continuity must be positively established (generation/epoch match, durable replay, explicit handling of outstanding IDs), never inferred from a successful HTTP status. ```python class SessionContinuityError(RuntimeError): """Raised when a resume appears to succeed at the transport layer but session continuity cannot be positively established.""" pass def resume_session(client, session_id, last_event_id, outstanding_ids): resp = client.post( "/mcp", headers={ "Mcp-Session-Id": session_id, "Last-Event-ID": str(last_event_id), }, json={"jsonrpc": "2.0", "id": client.next_id(), "method": "tools/list"}, ) if resp.status_code == 404: # Loud, recoverable: server does not know this session. client.reinitialize() return "reinitialized" if resp.status_code != 200: raise SessionContinuityError( f"unexpected resume status {resp.status_code}" ) replayed = resp.json().get("events", []) caught_up = any(ev["id"] >= last_event_id for ev in replayed) # The dangerous case: 200, no replay, but we still believe requests are live. if not caught_up and outstanding_ids: # Do NOT trust the session. Probe for liveness of each outstanding id. live = client.probe_outstanding(outstanding_ids) missing = set(outstanding_ids) - live if missing: raise SessionContinuityError( "resume returned 200 but outstanding requests " f"{sorted(missing)} are not live on the resumed session; " "continuity unproven (likely session-ID adoption across " "transport migration). Fail non-retryably; do not re-issue " "non-idempotent tools/call without idempotency keys." ) return "resumed" ```