# What structural signals indicate a resumable MCP streamable-session is actually resuming the same logical turn versus silently replaying a divergent one **Date of Record:** 2026 November 30 **Scope:** Applies to MCP servers and clients using the HTTP-native "streamable" transport with `Mcp-Session-Id` and `Last-Event-ID`-based resumption of a single logical request/turn. Does not cover stdio transport, pure SSE legacy transport without session IDs, or resumption across distinct logical turns (which is a new request, not a resume). ## Core Distinction A resumable streamable MCP session has two independent identities that operators routinely conflate: the **session identity** (`Mcp-Session-Id`, a server-issued opaque token that scopes server-side state) and the **stream position identity** (`Last-Event-ID`, a per-stream monotonic cursor into the event log of one in-flight request). Resumption is only semantically correct when *both* identities agree with the server's retained log. The failure mode this record isolates is **cursor-valid, session-valid, turn-divergent resumption**: the client presents a `Last-Event-ID` that the server's log *can* honor, under a session the server *does* recognize, but the events replayed after that cursor belong to a different logical turn than the one the client believes it is continuing. The transport handshake succeeds; the agent's reasoning state silently forks. This is distinct from hard resumption failure (404 on unknown session, 400 on unknown cursor), which is loud and recoverable. The dangerous case is the *quiet* one: HTTP 200, `text/event-stream`, events flowing, but the semantic continuity invariant is broken. ## What Was Observed An agent runtime issued a `tools/call` over streamable HTTP, received `Mcp-Session-Id: s_7f3a` and a stream of `message` events with IDs `e_100`…`e_118`, then the connection dropped mid-turn (proxy timeout at 30s) before the terminal `result` event. The client held `Last-Event-ID: e_118`. On reconnect the client re-sent the request with `Mcp-Session-Id: s_7f3a` and `Last-Event-ID: e_118`. The server returned 200 and immediately began emitting events `e_119`, `e_120`, … — but these were the continuation of a *retry* the server had internally initiated on its own timeout, keyed to a regenerated upstream model call. The event IDs were monotonic within the session's log, so they looked like a legitimate continuation. The replayed `e_119` carried a `progress` notification referencing a tool invocation ID (`inv_B`) that the client had never seen — the original turn's invocation was `inv_A`. The client's tool-call ledger had `inv_A` open; the stream was now reporting progress for `inv_B`. When the terminal `result` for `inv_B` arrived, the agent bound it to the `inv_A` call site, producing a tool result whose payload corresponded to a *different* set of arguments than the ones the agent had issued. The structural tell was not an error. It was three correlated signals in the resumed stream: (1) the first post-resume event's `id` was contiguous with the client's cursor but its embedded `invocationId` was not in the client's open-invocation set; (2) the resumed stream never re-emitted a `message` with the *original* request's correlation token; (3) the server's `Mcp-Session-Id` was unchanged but a server-side `traceparent`-equivalent header on the resumed response carried a different turn nonce than the original. ## Condition of Validity `Last-Event-ID`-based resumption is only a *semantic* resume under the conjunction of these invariants: 1. **Cursor monotonicity within a turn, not merely within a session.** Event IDs must be assigned from a per-turn sequence, or the server must embed a turn nonce in every event and reject resumption when the client's cursor and the server's retained log disagree on the nonce. A session-global counter satisfies the transport spec and violates the semantic invariant. 2. **Idempotent turn identity.** The resumed request must carry the *same* logical request identifier (a client-generated `requestId` or equivalent), and the server must refuse to resume a turn it has internally superseded or retried. If the server regenerates the turn on its own timeout, the old cursor is stale even though it is numerically valid. 3. **Event-log retention bound.** The server must retain events from the cursor forward for the duration it advertises; if it has garbage-collected `e_119`…`e_130` and re-numbered from a fresh counter, the client's `e_118` may collide with an unrelated event. Retention must be a declared, enforced bound, not best-effort. 4. **Correlation-token echo.** Every event in a resumable stream must echo the client's opaque correlation token (or a server-derived equivalent bound at turn start) so the client can verify, on the first post-resume event, that it is continuing the turn it thinks it is. When any of these is absent, resumption degrades from "continue the turn" to "continue *a* turn," and the client cannot distinguish the two from the transport layer alone. ## Decision Boundary The client-side decision boundary is: **on the first event after a resume, verify turn identity before feeding the event into the reasoning loop.** Concretely, the client must treat the resume as *provisional* until it has observed an event whose correlation token matches the turn it is resuming. If the first post-resume event carries an unknown invocation ID, an unknown turn nonce, or a correlation token that does not match, the client must **abandon the resume, discard the session's in-flight turn state, and re-issue the request as a new turn** — not splice the divergent stream into the existing ledger. The server-side decision boundary is symmetric: a resume request whose `Last-Event-ID` falls before the server's most recent turn-boundary marker for that session must be answered with an explicit `409 Conflict` (or a transport-level error event) rather than a silent continuation. The server must not "helpfully" resume across a turn boundary it created by retrying. The invariant that bounds the whole mechanism: **a resume is valid iff the server can prove, and the client can verify, that the cursor and the turn nonce co-refer to the same logical turn.** Either party alone cannot establish this; the protocol must carry enough structure for both to check. ## Operational Effect Without the turn-nonce check, agents exhibit a specific, reproducible pathology: **argument/result cross-binding**. The agent's tool-call ledger holds `inv_A` with arguments `A`; the resumed stream delivers a result computed for arguments `B`; the agent binds result-of-`B` to call-`A` and proceeds with a corrupted world model. Because the transport returned 200 and the events were well-formed, no error surfaces at the transport layer; the corruption manifests one or more reasoning steps later as a plan that references state the agent never actually established. In multi-step tasks this compounds: each subsequent tool call is issued against the corrupted binding, and the divergence is only detectable by replaying the event log against the invocation ledger. The guardrail is cheap: carry a turn nonce in every event, verify it on first post-resume event, and fail closed (re-issue as new turn) on mismatch. Servers that cannot guarantee per-turn cursor monotonicity must advertise resumption as best-effort and clients must not treat a resumed stream as a continuation of reasoning state without the nonce check. ```python class ResumptionDivergenceError(RuntimeError): """Raised when a resumed MCP streamable-session continues a different logical turn than the one the client believes it is resuming.""" pass def verify_resume_continuity( expected_turn_nonce: str, expected_open_invocations: set[str], first_event: dict, ) -> None: """ Called on the FIRST event received after a Last-Event-ID resume. Fails closed if the event does not co-refer to the turn being resumed. first_event is expected to carry: - "turnNonce": server-issued nonce bound at turn start - "invocationId": present on progress/result events for tool calls """ actual_nonce = first_event.get("turnNonce") if actual_nonce != expected_turn_nonce: raise ResumptionDivergenceError( f"resumed stream carries turn nonce {actual_nonce!r}, " f"expected {expected_turn_nonce!r}; cursor is valid but " f"turn-divergent — abandon resume, re-issue as new turn" ) inv = first_event.get("invocationId") if inv is not None and inv not in expected_open_invocations: raise ResumptionDivergenceError( f"resumed stream references invocation {inv!r} not in open set " f"{sorted(expected_open_invocations)!r}; server likely retried " f"the turn internally and re-numbered the log — refuse to splice" ) def resume_or_reissue( client, session_id: str, last_event_id: str, expected_turn_nonce: str, open_invocations: set[str], original_request: dict, ): stream = client.resume(session_id, last_event_id) first = next(stream) try: verify_resume_continuity(expected_turn_nonce, open_invocations, first) except ResumptionDivergenceError: # Fail closed: discard in-flight turn state, start a clean turn. client.discard_turn_state(session_id, expected_turn_nonce) return client.issue_new_turn(original_request) return client.continue_with(stream, first) ```