# When must an instance reject a resumed MCP SSE session because the Last-Event-ID cursor is sound but the session's capability epoch has advanced **Date of Record:** 2026 November 23 **Scope:** Applies to MCP servers exposing the HTTP-native streamable transport with an SSE fallback and `Mcp-Session-Id` / `Last-Event-ID` resumption, where a single session can span capability negotiation, tool registration changes, and server-side restarts. Does not apply to pure stdio transports, nor to sessions whose capability set is frozen for the session's entire lifetime by contract. ## Core Distinction The resumption cursor (`Last-Event-ID`) and the session's negotiated capability epoch are two independent state axes that the transport spec treats as if they were one. `Last-Event-ID` answers *"which bytes of the event stream has this client already consumed?"* The capability epoch answers *"which set of tools, resources, and prompt schemas was this client told about, and under which schema version is its in-flight reasoning valid?"* A streamable transport can resume the byte stream perfectly—replaying every event after the cursor with no gaps—while the capability epoch has silently advanced underneath it. The failure is not a lost event; it is a *coherent* stream of events that describes a world the client's cached schema no longer matches. The non-obvious part: the resumption succeeds. The SSE connection re-establishes, the server emits `200 OK` with `text/event-stream`, and events flow from the exact cursor. Every transport-level invariant holds. The breakage lives one layer up, in the agent's model of what the server can do, and it manifests only when the agent next invokes a tool whose input schema changed shape between epochs. ## What Was Observed A long-running agent session (`Mcp-Session-Id: 7f3a...`) negotiated capabilities at epoch 0: `search_documents` accepted `{query: str, limit: int}`. The agent issued a `tools/call` for `search_documents`, the server began streaming a large result set as SSE events, and the connection dropped mid-stream at `Last-Event-ID: 42` due to an upstream proxy idle timeout. While the client was disconnected, the server was redeployed. The new build registered `search_documents` with `{query: str, limit: int, filters: object}` where `filters` is required. The server's session store survived the redeploy (shared Redis), so session `7f3a...` still existed and its event log was still append-only from event 1. The client reconnected with `Last-Event-ID: 42`. The server: 1. Found session `7f3a...` alive in the store. 2. Replayed events 43..N from the log—the remainder of the `search_documents` result stream, correctly framed. 3. Returned `200 OK` with `text/event-stream`. The agent received a complete, gap-free result stream. Nothing in the transport signalled that the tool schema had changed. On the *next* turn the agent, still holding epoch-0 schema in its context, called `search_documents` with only `{query, limit}`. The server's new validator rejected it with an `isError: true` result citing a missing `filters` field. The agent—reasoning over a result stream it believed was authoritative for the current epoch—treated the schema error as a transient tool fault, retried twice, then hallucinated a `filters` value to satisfy the validator, producing a semantically wrong query that nonetheless executed. The transport had done its job flawlessly. The invariant "resumed stream is contiguous with pre-disconnect stream" was satisfied. The invariant "resumed session's capability view matches the server's current capability view" was violated, and nothing in the resumption handshake checked it. ## Condition of Validity Resuming a session with a `Last-Event-ID` cursor is *sound* only when all of the following hold: - The session's capability epoch is unchanged between the disconnect and the resume, **or** - The server, on resume, emits a capability-invalidation event (e.g. `notifications/tools/list_changed`) *at the cursor boundary* before replaying any subsequent tool-result events, **or** - The client, on resume, re-issues `initialize`/`tools/list` and reconciles before consuming replayed events. The failure is *reachable* precisely when: (a) session state (including event log) is durable across server restarts or redeploys, (b) the tool/resource schema set is mutable within a session's lifetime, and (c) the resumption path replays events without re-validating the capability epoch. Any two of these are safe; all three together produce the silent-epoch-advance failure. The condition is *invalid* (i.e. resumption is unsafe) whenever the server cannot prove epoch equality, because the client's cached schema is load-bearing for its own reasoning and cannot be assumed to self-heal. ## Decision Boundary The decision the server must make on every `Last-Event-ID` resume is binary and must be made *before* replay: - **Resume in place** if and only if `session.epoch == current_server_epoch` for the session's negotiated capability set. Replay events from the cursor. - **Reject-and-renegotiate** if `session.epoch != current_server_epoch`. Do not replay. Return a `409 Conflict` (or a transport-level `initialize`-required signal) with the session's *old* epoch and the *current* epoch, forcing the client to re-run capability negotiation and then resume from the cursor *after* reconciliation. The trap is choosing "resume in place" because the cursor is valid. Cursor validity is necessary but not sufficient. The epoch check is the missing conjunct, and it must be evaluated against the capability set the client actually holds—not against whatever the server currently advertises, which is exactly the value that changed. A client-side mirror of this boundary: an agent must treat any resumed stream as *provisional* until it has confirmed the epoch. It may buffer replayed events but must not act on them—specifically must not derive tool calls from them—until epoch reconciliation completes. Buffering without acting is the safe posture; acting on replayed events under a stale schema is the failure. ## Operational Effect The practical consequence is that **stream contiguity and schema coherence are orthogonal, and only one of them is protected by the resumption token**. Systems that conflate them will pass every transport test—reconnection, gap-free replay, ordering—while failing at the reasoning layer, and the failure will present as the agent's fault (bad tool arguments, spurious retries, hallucinated parameters) rather than as a transport defect. This misattribution is the expensive part: operators debug the agent's tool-calling prompt while the actual cause is a server that resumed a session across an epoch boundary. The guardrail is a single mandatory check on the resume path, cheap to implement and impossible to reconstruct after the fact: stamp every session with the capability epoch it was negotiated under, stamp every server build with its epoch, and refuse in-place resumption on mismatch. The client's obligation is symmetric: never derive a tool call from a replayed event until the epoch is confirmed current. Enforce both, and the silent-epoch-advance class is bounded to a visible `409` instead of a hallucinated `filters` object. ```python class CapabilityEpochMismatch(RuntimeError): """Raised when a session resume would replay events under a stale capability epoch.""" pass class SessionRecord: def __init__(self, session_id: str, epoch: int, event_log: list): self.session_id = session_id self.epoch = epoch self.event_log = event_log # append-only, indexed by event id def resume_stream(session: SessionRecord, last_event_id: int, server_epoch: int): # Transport-level cursor validity: the client has consumed up to last_event_id. if last_event_id < 0 or last_event_id > len(session.event_log): raise CapabilityEpochMismatch( f"cursor {last_event_id} outside session {session.session_id} log bounds" ) # The missing conjunct: capability epoch must match before any replay. # A valid cursor is necessary but NOT sufficient for a sound resume. if session.epoch != server_epoch: raise CapabilityEpochMismatch( f"session {session.session_id} negotiated at epoch {session.epoch}, " f"server now at epoch {server_epoch}; refuse in-place replay, " f"force renegotiation before resuming from cursor {last_event_id}" ) # Safe: epoch stable, replay from cursor. return session.event_log[last_event_id:] ```