# When must an instance refuse to resume an MCP SSE session after migration to Streamable HTTP because the Last-Event-ID cursor is not causally anchored to the new transport's event space **Date of Record:** 2026 November 25 **Scope:** Applies to MCP clients that persist a `Last-Event-ID` cursor from a legacy HTTP+SSE transport and attempt to resume against a server that has migrated to Streamable HTTP (single-endpoint POST + optional GET stream). Does not apply to greenfield Streamable HTTP sessions that never observed the SSE transport, nor to in-process transports. ## Core Distinction The failure is not "resumption is broken." It is that resumption *succeeds silently* with a cursor that is syntactically valid but semantically unbound. Under legacy MCP HTTP+SSE, `Last-Event-ID` is a monotonic integer the server issues per SSE stream; the server holds a replay buffer keyed by that integer and can deterministically re-emit every event after it. Under Streamable HTTP, the event ID space is *redefined by the new server implementation* — it may be a UUID, a per-session counter reset on migration, a hash, or a composite of `(session_id, seq)`. A client that reconnects with an old SSE integer `Last-Event-ID: 47` against a Streamable HTTP endpoint is asserting a causal position in an event space that no longer exists. The server cannot distinguish "47 means event 47 in my buffer" from "47 is a foreign cursor I should ignore" — and different implementations resolve this ambiguity in opposite, both-plausible ways. The invariant that must hold before resumption is legal: **the cursor's event-ID namespace must be provably the same namespace the server will replay from.** Migration breaks this invariant without breaking the wire protocol, so no transport-level error is raised. ## What Was Observed A client agent had an active SSE session, cursor at `Last-Event-ID: 47`, mid-task, with a pending tool call awaiting a `tools/call` result delivered over the SSE stream. The server was redeployed to a Streamable HTTP MCP endpoint behind the same URL. On reconnect: 1. Client issues `GET /mcp` with `Accept: text/event-stream` and `Last-Event-ID: 47`. 2. New server's Streamable HTTP handler accepts the GET, opens a stream, and — because its replay buffer is keyed by `(session_id, seq)` and it sees no matching session — treats `Last-Event-ID: 47` as an opaque, unknown token. Two behaviors were observed across implementations: - **Silent-drop server:** ignores the header, replays nothing, streams only *new* events. The pending `tools/call` result (emitted at old event 48) is never delivered. The agent blocks on a tool result that will never arrive. - **Naive-echo server:** interprets `47` as a sequence number in its *new* per-session counter, replays events 48..N from an unrelated session that happens to share the integer range, delivering foreign `tools/call` results and notifications into the agent's context. 3. In both cases the HTTP layer returns `200 OK`. There is no protocol-level signal that resumption was semantically void. The observed damage in the echo case is worse than the drop case: the agent's context is poisoned with another session's tool outputs, and because tool-call IDs are also just strings, a colliding `id` can cause the agent to accept a foreign result as its own. ## Condition of Validity Resumption across a transport migration is valid **only if** the client can establish, before replaying, that the server's event-ID space is the same one the cursor was minted in. Concretely, at least one of: - The server advertises a stable `event_id_namespace` (or equivalent epoch/session-generation token) in the `initialize` result, and the client's stored cursor carries the matching namespace tag. - The cursor is restructured at the transport layer to be self-describing: e.g. `Last-Event-ID: :`, and the server rejects (not silently accepts) a cursor whose namespace does not match its own. - The migration is accompanied by an explicit session-invalidation handshake: the new endpoint returns `409 Conflict` (or a defined MCP error) for any `Last-Event-ID` it cannot anchor, forcing the client to re-`initialize` and replay from a durable checkpoint rather than from a transport cursor. Absent any of these, the cursor is a *dangling causal reference*. The condition of validity is false, and the client must not resume — it must re-initialize and recover task state from its own durable checkpoint (semantic memory), not from the transport buffer. ## Decision Boundary The boundary is not "old cursor vs. new cursor." It is **"is the cursor an authoritative pointer into replayable state, or merely a hint?"** - If the server guarantees deterministic replay from the cursor *and* the cursor's namespace is verified → resume; the transport is a valid source of truth for in-flight events. - If the namespace cannot be verified → the cursor is a hint only. The client must treat the transport as lossy and fall back to its own checkpoint. Resuming on an unverified cursor is the failure. - The dangerous middle case is the naive-echo server: it *appears* to honor the cursor, so the client's own verification (which only checks HTTP 200 and stream liveness) passes. The decision must key on namespace identity, not on liveness. A second boundary: even a correctly-namespaced cursor does not survive a server that dropped its replay buffer during redeploy. Namespace match is necessary, not sufficient; the server must also signal buffer availability (e.g. `Last-Event-ID` older than buffer head → `410 Gone`), and the client must treat `410` as "checkpoint, don't resume." ## Operational Effect Without the guardrail, migrated sessions exhibit *silent task divergence*: the agent either hangs on an undelivered tool result (drop case) or executes on foreign tool outputs (echo case), and because the failure is at the transport cursor layer rather than the reasoning layer, no reasoning-loop detector fires. The agent's error-compounding is invisible until a downstream tool call fails with inputs derived from a foreign result. The guardrail is: tag every persisted cursor with the event-ID namespace observed at `initialize`; on reconnect, require the server to confirm the namespace (via `initialize` result field or cursor round-trip validation) before issuing `Last-Event-ID`; on any mismatch, ambiguous, or `410` response, discard the cursor and resume from the durable task checkpoint. This converts an unbounded, silent divergence into a bounded, loud re-initialization. ```python import re from dataclasses import dataclass class UnanchoredCursorError(RuntimeError): """Raised when a persisted Last-Event-ID cannot be proven to belong to the server's current event-ID namespace. Resuming would be a silent causal-reference failure (drop or foreign-replay).""" @dataclass(frozen=True) class Cursor: namespace: str seq: int def header(self) -> str: return f"{self.namespace}:{self.seq}" _CURSOR_RE = re.compile(r"^(?P[A-Za-z0-9._-]+):(?P\d+)$") def parse_cursor(raw: str) -> Cursor: m = _CURSOR_RE.match(raw) if not m: # Legacy bare integer from SSE era: namespace unknown. raise UnanchoredCursorError( f"cursor {raw!r} has no namespace tag; cannot anchor to Streamable HTTP event space" ) return Cursor(namespace=m.group("ns"), seq=int(m.group("seq"))) def decide_resume( stored_raw: str, server_namespace: str, server_buffer_head: int | None, ) -> Cursor | None: """Return a cursor safe to send, or None to force checkpoint-based recovery.""" try: cursor = parse_cursor(stored_raw) except UnanchoredCursorError: return None # cannot verify; do not resume if cursor.namespace != server_namespace: # Different event space: replaying would be meaningless or foreign. return None if server_buffer_head is None: # Server has no replay buffer (e.g. post-redeploy). Namespace match # is necessary but not sufficient. return None if cursor.seq < server_buffer_head: # Cursor fell off the replay window; server would 410. return None return cursor def resume_stream(stored_raw: str, server_namespace: str, server_buffer_head: int | None) -> str: cursor = decide_resume(stored_raw, server_namespace, server_buffer_head) if cursor is None: raise UnanchoredCursorError( f"refusing to resume with cursor {stored_raw!r} against namespace " f"{server_namespace!r} (buffer_head={server_buffer_head}); " "re-initialize and recover from durable checkpoint" ) return cursor.header() ```