# Where must an instance reconcile MCP Streamable HTTP resumption against a replayed SSE event ID before it may treat a tool call as committed **Date of Record:** 2026 November 27 **Scope:** Applies to MCP clients and servers using the Streamable HTTP transport with `Last-Event-ID` resumption on a POST-initiated SSE stream that carries tool-call results. Does not apply to stdio transport, to stateless per-request HTTP without an event store, or to WebSocket-based MCP variants where the transport itself guarantees ordered, gap-free delivery. ## Core Distinction The distinction that matters is between *transport-level resumption* and *semantic-level commit*. The MCP Streamable HTTP extension lets a client reconnect to a dropped SSE stream by presenting `Last-Event-ID`, and the server replays events with IDs greater than that value. This is a delivery guarantee about bytes on the wire. It is **not** a guarantee about what the agent's reasoning loop has durably recorded. The failure mode lives in the gap between the two: an SSE event ID that the client has *received* but not yet *applied* to its own state is a resumption cursor that will silently skip work. The boundary invariant is: **the resumption cursor must advance only after the event's semantic effect is committed to the client's durable task state, never merely on receipt.** A second, sharper distinction: event IDs are opaque and server-chosen. A conformant server may reuse an ID namespace across reconnects, may emit IDs that are monotonic per-stream but not globally ordered, and may replay a *different* event body under an ID the client has already seen if the server's event store was rebuilt. The client cannot assume "ID seen = effect applied" nor "ID unseen = effect not applied." It can only assume ordering *within a single stream instance that the server attests to*. ## What Was Observed A tool-calling agent issued `tools/call` for a long-running operation (a database migration status poll) over a POST-initiated SSE stream. The server assigned event IDs `1001` (progress 40%), `1002` (progress 80%), `1003` (final result: `{"status":"committed","rows":41233}`). The network dropped after the client's HTTP layer had buffered `1003` into the socket but before the agent's event handler had processed it. The client's SSE reader had already advanced its `lastEventId` field to `1003` at the parsing layer—this is the natural implementation, since the ID field is parsed before the data field is dispatched. On reconnect the client sent `Last-Event-ID: 1003`. The server, whose event store retained events only for a 60-second window and had already evicted `1001`–`1003`, returned `200 OK` with an empty replay and then continued live streaming from `1004` (a heartbeat). The client saw a clean stream with no gap indicator. The agent's task state still held `status: "in_progress"` because `1003`'s data was never dispatched to the handler. The agent then re-issued `tools/call` for the same migration poll. The server, treating it as a new call, started a second migration status query—harmless here, but the same pattern against a `tools/call` that mutates state (e.g., `apply_migration`) produced a duplicate application. The observable signature: **the client's resumption cursor was ahead of its committed state, and the server had no way to detect the divergence because the cursor is client-asserted and the server's replay window had closed.** Neither side violated the letter of the spec. The stream was resumable; the resumption was simply semantically empty. A second observation from the same incident class: when the server's event store *did* retain the events, it replayed `1003` correctly, but the client's dedup layer—keyed on event ID—suppressed it as "already seen," because the ID had been recorded at parse time. The replay was correct and the client discarded it. Both failure directions (premature cursor advance, and ID-keyed dedup of a re-delivered effect) trace to the same root: treating the SSE ID as a proxy for semantic application. ## Condition of Validity The invariant "advance cursor only on commit" is valid and sufficient only under these conditions: 1. **The client maintains a durable, ordered task-state log** separate from the SSE parser, and the cursor is a projection of that log's high-water mark, not a parser field. 2. **Event IDs are server-attested as monotonic and gap-free within a stream instance**, and the server exposes (or the client can infer) whether the replay window covers the requested `Last-Event-ID`. If the server cannot attest coverage, the client must treat resumption as *best-effort* and re-verify any `tools/call` whose result it did not durably observe. 3. **Tool calls are idempotent or carry a client-generated idempotency key** that the server deduplicates, so that a re-issued call after ambiguous resumption is safe. 4. **The client distinguishes "event received" from "event applied"** in its own telemetry, so that a resumption that delivers zero events can be detected as *possibly lossy* rather than *clean*. When condition 2 fails—no coverage attestation—the correct behavior is not to trust the cursor but to reconcile: query the server for the call's terminal state by call ID before re-issuing. The spec permits this; it does not require the server to make coverage inferable, which is exactly why the client must not assume it. ## Decision Boundary The boundary is drawn at the point where the client decides whether a resumption with an empty or partial replay means "nothing was missed" or "something may have been missed." The decision procedure: - If the server's response to the resumption includes an explicit replay-window or coverage signal (e.g., a `resumption-truncated` flag, or a `Last-Event-ID` echo indicating the earliest retained ID), and the requested cursor is within coverage, then an empty replay is *authoritative*: nothing was missed, proceed. - If coverage is not attested, an empty replay is *ambiguous*. The client must not advance any tool call from `pending` to `committed` on the strength of the resumption alone. It must issue a state reconciliation query keyed on the call's idempotency key. - If the replay delivers events the client has already applied (per its durable log, not per parser state), they are *idempotently re-applied*—the log's commit is the dedup key, not the SSE ID. - If the replay delivers an event whose ID is *lower* than the client's durable high-water mark but whose body differs from the recorded body for that ID, the server's event store has been rebuilt or the ID namespace reused. This is a hard fault: the client cannot order events across the rebuild and must abort the stream and re-establish task state from an authoritative source. The non-obvious boundary: **an empty replay after a reconnect is the most dangerous resumption outcome, not the safest.** It looks like a clean resume. It is indistinguishable, without coverage attestation, from a silent gap. ## Operational Effect The practical consequence is that MCP Streamable HTTP clients must carry a *commit cursor* distinct from the *parse cursor*, and servers should emit coverage metadata on resumption. Without this, agents exhibit a specific pathology: **post-resumption duplicate side effects and phantom completions**—tool calls re-issued because their results were parsed-but-not-applied, and tasks marked complete because a heartbeat arrived after a gap that swallowed the terminal event. The guardrail is a two-phase resumption: reconnect, request coverage, reconcile ambiguous calls by idempotency key, *then* resume live streaming. The cost is one extra round-trip per reconnect; the alternative is non-deterministic duplicate mutation in exactly the failure conditions (network drop mid-result) where it is hardest to observe. ```python import time from dataclasses import dataclass, field from typing import Optional class ResumptionIntegrityError(RuntimeError): """Raised when SSE resumption cannot be reconciled with durable task state.""" @dataclass class DurableTaskLog: # high-water mark of *applied* events, not parsed events commit_cursor: int = 0 applied: dict = field(default_factory=dict) # event_id -> body_hash call_state: dict = field(default_factory=dict) # idempotency_key -> "pending"|"committed" @dataclass class ReplayResponse: requested_last_event_id: int earliest_retained_id: Optional[int] # None => server does not attest coverage events: list # list of (event_id, body, body_hash) def reconcile_resumption( log: DurableTaskLog, replay: ReplayResponse, pending_call_keys: list, ) -> DurableTaskLog: """ Apply a resumption replay to durable state under the commit-cursor invariant. Raises ResumptionIntegrityError when the replay cannot be ordered or trusted. """ # 1. Coverage check: can we trust an empty/partial replay? coverage_attested = replay.earliest_retained_id is not None covers_cursor = ( coverage_attested and replay.earliest_retained_id <= log.commit_cursor + 1 ) if not replay.events and not covers_cursor: # Empty replay with no coverage attestation is ambiguous, not clean. # Do NOT advance commit_cursor. Force reconciliation of pending calls. for key in pending_call_keys: if log.call_state.get(key) == "pending": raise ResumptionIntegrityError( f"ambiguous resumption: no coverage attestation and no replay " f"for pending call {key!r} at cursor {log.commit_cursor}; " f"must reconcile by idempotency key before re-issuing" ) return log # 2. Order and idempotency check against the durable log. for event_id, body, body_hash in replay.events: if event_id <= log.commit_cursor: prior = log.applied.get(event_id) if prior is not None and prior != body_hash: # Same ID, different body: event store rebuilt / ID namespace reused. raise ResumptionIntegrityError( f"event {event_id} replayed with divergent body " f"(recorded {prior}, got {body_hash}); cannot order across rebuild" ) # Idempotent re-apply: already committed, skip without re-effect. continue if event_id != log.commit_cursor + 1: raise ResumptionIntegrityError( f"gap in replay: expected {log.commit_cursor + 1}, got {event_id}" ) # Apply semantic effect, THEN advance cursor. _apply_effect(log, body) log.applied[event_id] = body_hash log.commit_cursor = event_id return log def _apply_effect(log: DurableTaskLog, body: dict) -> None: key = body.get("idempotency_key") if key and body.get("terminal"): log.call_state[key] = "committed" ```