In what scenarios must an instance treat an MCP streamable-session resumption as a fresh capability negotiation rather than a continuation, and how does the SSE-to-streamable upgrade silently break `Last-Event-ID` replay

**Date of Record:** 2026 December 2 **Scope:** Applies to MCP clients and servers using the HTTP-native transport where a legacy SSE session is upgraded (or re-established) into a streamable HTTP session, or where a streamable session is resumed via `Last-Event-ID` after a disconnect. Does not apply to pure stdio transports, nor to sessions that never carried server-initiated notifications across the boundary.

Core Distinction

The failure mode is not "the connection dropped." It is the conflation of two different identities that the streamable transport overloads onto a single token: the **session identity** (which governs capability negotiation, tool schema binding, and server-side state) and the **event cursor** (`Last-Event-ID`, which governs replay of the notification stream). In the legacy SSE transport these were implicitly coupled — one long-lived GET stream carried both the session and every event on it, so a reconnect with `Last-Event-ID` was unambiguously a continuation of *that* stream on *that* session. The streamable HTTP transport decouples them: the session is established by `initialize` and carried in a header (typically `Mcp-Session-Id`), while events flow on potentially many independent POST/GET streams tagged with event IDs. An upgrade from SSE to streamable, or a resume across a transport that has changed its event-ID namespace, preserves the *cursor* syntactically while invalidating the *capabilities* it was negotiated against. The instance that treats the resumed cursor as proof of a valid continuation — replaying it into a session whose negotiated tool set, schema versions, or server-side resource handles have changed — is the one that corrupts state.

What Was Observed

A client agent held a legacy SSE session against an MCP server. Mid-task, after the server was redeployed behind a streamable-HTTP-capable gateway, the client's GET stream was severed (gateway idle timeout, 60s). The client reconnected using streamable semantics: it issued `initialize` on a fresh POST, received a new `Mcp-Session-Id`, and — because its reconnect logic was written for the old transport — attached the *last observed* `Last-Event-ID` from the prior SSE stream to the new session's GET.

Three things then happened in sequence:

  1. The new session's event-ID namespace was freshly minted starting at a different epoch. The server, receiving a `Last-Event-ID` from a namespace it did not recognize for *this* session, did one of two things depending on implementation: it either (a) silently ignored the cursor and began replaying from the current head, or (b) attempted to resolve the cursor against a shared event store and replayed events that belonged to the *prior* session's tool-call lifecycle.
  2. In case (b), the replayed notifications referenced `progressToken` and `requestId` values from tool invocations that the new session had never issued. The client's in-flight-call table had no entry for them; its handler either dropped them (losing progress) or, worse, matched them by token to a *newly issued* call that happened to reuse an integer token, injecting stale progress and a stale `result` into a live call.
  3. The client's capability state was now internally inconsistent: it believed it held the old session's negotiated subscriptions (e.g., `resources/subscribe` on a URI) but the new session had never been told to subscribe. Server-initiated `notifications/resources/updated` for that URI never arrived, and the agent's memory of the resource silently drifted stale — a retrieval mismatch that surfaced only many turns later.

The distinguishing signature: the agent did not crash. It produced plausible-but-wrong state, because the resumed cursor was *syntactically valid* and *semantically orphaned*.

Condition of Validity

A resumption may be treated as a true continuation **only if all of the following hold simultaneously**:

If any one fails, the invariant that must be enforced is: **the cursor is discarded, the session is re-negotiated from scratch, and every in-flight call, subscription, and progress token from the prior session is marked orphaned and reconciled — not resumed.**

Decision Boundary

The boundary is not "did the connection succeed." It is "does the event-ID space I am presenting provably belong to the session and capability-set I am presenting alongside it." Concretely:

The trap is that the upgrade path from SSE to streamable *always* lands in the "new session ID" row while *feeling* like the "same session ID" row, because the human-visible task, the agent's context window, and the tool names are all unchanged. The decision must be made on transport identity, not task continuity.

Operational Effect

Agents that violate this boundary exhibit a characteristic late-binding corruption: stale replayed results get attributed to live calls, subscriptions silently lapse into stale-memory drift, and the failure surfaces turns later as a retrieval mismatch the agent cannot trace back to the reconnect. The guardrail is a hard rule in the reconnect handler — **a cursor is only valid within the session and capability-hash that minted it** — plus a server obligation to emit an explicit `resume-unsupported` rather than resetting to head. When either side cannot prove the triple (session ID, capability hash, cursor range), the correct action is re-negotiation with explicit orphaning of prior in-flight state, accepting the cost of re-issuing calls over the cost of silent state corruption.

import hashlib
import json
from dataclasses import dataclass, field


class ResumptionInvariantViolation(RuntimeError):
    """Raised when a streamable-session resume would replay a cursor across
    a session or capability boundary it does not belong to."""


@dataclass
class SessionBinding:
    session_id: str
    capabilities: dict
    event_epoch: str  # server namespace tag for Last-Event-ID

    def capability_hash(self) -> str:
        blob = json.dumps(self.capabilities, sort_keys=True).encode()
        return hashlib.sha256(blob).hexdigest()


@dataclass
class ResumeRequest:
    session_id: str
    capabilities: dict
    last_event_id: str
    event_epoch: str


@dataclass
class InFlightCall:
    request_id: int
    progress_token: int
    tool: str
    orphaned: bool = False


def classify_resume(
    prior: SessionBinding,
    req: ResumeRequest,
    cursor_in_range: bool,
    server_signaled_unsupported: bool,
    in_flight: list[InFlightCall] = field(default_factory=list),
) -> str:
    # New session ID after an SSE->streamable upgrade: cursor is foreign.
    if req.session_id != prior.session_id:
        for call in in_flight:
            call.orphaned = True
        return "renegotiate_discard_cursor"

    # Same session, but capabilities drifted (hot-swapped tools/schemas).
    if req.capabilities != prior.capabilities:
        for call in in_flight:
            call.orphaned = True
        return "renegotiate_invalidate_changed_calls"

    # Same session, same capabilities, but event namespace changed.
    if req.event_epoch != prior.event_epoch:
        for call in in_flight:
            call.orphaned = True
        return "renegotiate_discard_cursor"

    # Server cannot prove the cursor is in range: silent head-reset is forbidden.
    if server_signaled_unsupported or not cursor_in_range:
        raise ResumptionInvariantViolation(
            f"session {req.session_id}: cursor {req.last_event_id!r} not "
            f"provably in-range for epoch {req.event_epoch!r}; "
            "refusing silent head-reset, re-negotiation required"
        )

    return "resume"


def resume_or_fail(prior: SessionBinding, req: ResumeRequest,
                   cursor_in_range: bool, server_signaled_unsupported: bool,
                   in_flight: list[InFlightCall]) -> str:
    verdict = classify_resume(prior, req, cursor_in_range,
                              server_signaled_unsupported, in_flight)
    if verdict != "resume":
        # Caller must re-initialize and re-subscribe; orphaning is enforced above.
        return verdict
    if not all(not c.orphaned for c in in_flight):
        raise ResumptionInvariantViolation(
            "resume accepted but in-flight calls were orphaned — state machine bug"
        )
    return verdict