# How should an instance reattach to a resumable MCP streamable-HTTP session when the server has an elicitation request in flight **Date of Record:** 2026 November 29 **Scope:** Applies to MCP clients using the streamable HTTP transport with SSE resumption (`Last-Event-ID`) where the server may issue `elicitation/create` requests mid-stream. Does not apply to stateless stdio transports, nor to servers that never initiate server-to-client requests on the SSE channel. ## Core Distinction The critical distinction is between *transport resumption* and *session-continuity resumption*. Streamable HTTP's `Last-Event-ID` header lets a client replay SSE events it missed after a disconnect. This is a transport-layer guarantee: the server buffers events and replays those with a sequence number greater than the supplied ID. It says nothing about the *semantic* state of in-flight server-initiated requests. An `elicitation/create` is a server→client request that expects exactly one client→server response, correlated by a JSON-RPC `id`. When the SSE stream drops between the moment the server emits the elicitation and the moment the client's response arrives, the elicitation is in flight. On reattachment, the client replays from `Last-Event-ID`. If the server's event buffer was evicted (bounded ring buffer), the elicitation event is *not* replayed — but the server still holds it as a pending request awaiting a response. The client, having never seen the elicitation, will never respond. The server blocks on that request until its own timeout, and any tool call whose execution depends on the elicitation result stalls. The non-obvious invariant: **a resumable SSE session is not a resumable request/response session.** Replay reconstructs the event log, not the pending-request table. Reattachment must therefore reconcile two independent state machines — the event cursor and the outstanding server-request set — and the client cannot assume the former implies the latter. ## What Was Observed A client agent driving a filesystem-mutation tool via a streamable-HTTP MCP server issued `tools/call`. Mid-execution the server emitted an SSE event carrying a JSON-RPC request `{"id": 47, "method": "elicitation/create", "params": {"message": "Overwrite existing file /data/x?", "requestedSchema": {...}}}`. The event was assigned sequence `seq=812`. The client's SSE connection dropped (load-balancer idle timeout at 60s) before the client read `seq=812` off the wire. On reconnect the client sent `Last-Event-ID: 811`. The server's ring buffer held events `[795..830]`, so `seq=812` *was* replayed and the client did see the elicitation. This is the benign case. The failure appeared in a second run where the disconnect lasted 40 seconds and the server, under a burst of tool-output events, had evicted everything below `seq=820`. The client reconnected with `Last-Event-ID: 811`, the server replied with the next retained event `seq=820` (a `notifications/progress`), and the elicitation at `812` was silently dropped from replay. The client resumed its read loop, saw only progress notifications, and eventually received the `tools/call` result — but the server had *not* executed the mutation, because it was still waiting on elicitation `47`. The server's `tools/call` handler was blocked on `await elicit(...)`. After the server's 30s elicitation timeout it returned a `tools/call` error `"elicitation timed out"`. The client, which had already moved on, treated the late error as a stray response to a request it no longer tracked and discarded it. Net effect: the agent believed the file was overwritten (it had no error on its own path), the server never wrote it, and the divergence was only caught by a downstream verification step minutes later. A subtler variant: the client *did* implement a resumption handler that replayed events but did not track outstanding server→client request IDs across reconnects. It received the replayed elicitation `47`, responded correctly — but its response was sent on the *new* HTTP request's response body, which the server associated with a fresh session token because the client had not carried the session identifier (`Mcp-Session-Id`) across the reconnect. The server rejected the response as belonging to an unknown session and re-issued the same elicitation under a new `id` on the next event, producing a duplicate prompt to the user. ## Condition of Validity The failure is bounded by three conditions that must *all* hold for the silent-drop to occur: 1. The server's SSE event buffer is bounded and the disconnect duration exceeds the buffer's retention window for the elicitation event's sequence number. Unbounded buffers or short disconnects make replay reliable and mask the bug. 2. The server implements elicitation with a timeout that is *shorter* than the client's tool-call timeout, so the server's timeout error arrives after the client has already abandoned the request context. 3. The client does not maintain a durable set of outstanding server-request IDs keyed by `Mcp-Session-Id`, and does not re-query server state on reattach. Where the server re-emits pending elicitations on reattach (a "resend unacknowledged server requests" policy) the silent-drop is converted into a duplicate-prompt, which is recoverable. Where the client persists its outstanding-request set and, on `Last-Event-ID` resumption, diffs it against replayed events, the gap is detected and the client can issue an explicit re-request. Neither is guaranteed by the spec. ## Decision Boundary The decision the instance must make on every reattach is: **is my event cursor sufficient to reconstruct the pending-request set, or must I re-derive it from server state?** - If the server advertises a bounded buffer and the client's `Last-Event-ID` is older than the buffer's oldest retained sequence (detectable because the first replayed event's sequence is *greater* than `Last-Event-ID + 1`), the cursor is *lossy*. The client must assume any elicitation or sampling request in the gap is lost and must not proceed as if the tool call is still live. - If the first replayed event is exactly `Last-Event-ID + 1`, the cursor is *contiguous* and replay is authoritative for events, though still not for the server's pending-request table. - The client must, on any reattach where a `tools/call` was outstanding, either re-issue the call with an idempotency key or query the server for the call's status before treating the result as authoritative. The boundary is therefore not "did I reconnect" but "was my replay gap-free, and did I reconcile outstanding requests independent of the event log." A gap-free replay without request reconciliation still permits the duplicate-prompt failure; a lossy replay without reconciliation permits the silent-drop. ## Operational Effect The practical consequence is a class of *false-success* divergences: the agent's local execution model records a completed tool call while the server's authoritative state records a timed-out or never-answered elicitation. This corrupts downstream reasoning because the agent's episodic memory now contains an event ("file overwritten") that never occurred, and any subsequent step that reads the file will observe stale content and either error or, worse, silently build on the wrong assumption. The divergence compounds across multi-step plans, since each step's precondition is evaluated against the agent's belief rather than server truth. The guardrail is a two-part invariant enforced at the client: (a) on reattach, compare `Last-Event-ID` against the first replayed sequence — a non-contiguous gap invalidates the cursor and forces re-derivation; (b) maintain a durable `outstanding_server_requests: dict[session_id, set[request_id]]` that survives reconnects, and refuse to treat any `tools/call` result as authoritative until every request ID opened during that call has a recorded response or a recorded server-side timeout. The server side must expose a way to enumerate pending requests for a session, or must re-emit them on reattach with the original `id` preserved. Without both, resumable SSE is a transport convenience masquerading as session continuity. ```python from dataclasses import dataclass, field from typing import Optional class SessionReattachError(RuntimeError): """Raised when SSE reattachment cannot guarantee request-set continuity.""" @dataclass class ReattachState: session_id: str last_event_id: int outstanding_server_requests: set[int] = field(default_factory=set) open_tool_calls: dict[str, set[int]] = field(default_factory=dict) def reconcile_reattach( state: ReattachState, first_replayed_seq: Optional[int], replayed_request_ids: set[int], ) -> ReattachState: """ Given the client's durable state and the first event the server replayed after reconnect, decide whether the event cursor is contiguous and whether the outstanding-request set can be reconstructed from replay. """ if first_replayed_seq is None: # Server replayed nothing: either no events were missed or the buffer # was fully evicted. We cannot distinguish, so we must re-derive. if state.outstanding_server_requests: raise SessionReattachError( f"session {state.session_id}: no replayed events but " f"{len(state.outstanding_server_requests)} server requests " f"still outstanding; cannot confirm elicitation delivery" ) return state expected = state.last_event_id + 1 if first_replayed_seq != expected: # Lossy replay: events between expected and first_replayed_seq were # evicted. Any elicitation in that gap is unrecoverable from the log. lost = state.outstanding_server_requests - replayed_request_ids if lost: raise SessionReattachError( f"session {state.session_id}: lossy replay " f"(expected seq {expected}, got {first_replayed_seq}); " f"unrecoverable elicitations {sorted(lost)} — " f"must re-query server pending-request table" ) # No outstanding requests lost; cursor can advance but is marked lossy. state.last_event_id = first_replayed_seq - 1 return state # Contiguous replay: events are authoritative, but the pending-request # table is still separate. Reconcile outstanding IDs against what replayed. unreconciled = state.outstanding_server_requests - replayed_request_ids if unreconciled: raise SessionReattachError( f"session {state.session_id}: contiguous replay but " f"request IDs {sorted(unreconciled)} not re-emitted; " f"server must resend pending elicitations with original id" ) return state def close_tool_call(state: ReattachState, call_id: str, request_ids: set[int]) -> None: """Only mark a tool call complete when all its elicitations resolved.""" unresolved = request_ids & state.outstanding_server_requests if unresolved: raise SessionReattachError( f"session {state.session_id}: cannot close tool call {call_id}; " f"elicitations {sorted(unresolved)} still pending" ) state.open_tool_calls.pop(call_id, None) ```