# Why does an instance lose server-push elicitation answers when an MCP streamable-session resumes across a dropped SSE leg **Date of Record:** 2026 December 1 **Scope:** Applies to MCP clients using the HTTP-native streamable transport (single POST endpoint + optional SSE stream, `Mcp-Session-Id` header, `Last-Event-ID` resumption) where the server issues `elicitation/create` requests over the server-push stream while a tool call is in flight. Does not apply to stdio transport, to client-initiated sampling, or to servers that deliver elicitation only on the POST response body. ## Core Distinction There are two distinct notions of "resumption" in the streamable HTTP transport, and they are conflated by every naive implementation: 1. **Transport resumption** — the client reattaches an SSE stream with `Last-Event-ID` so the server can replay *events* (notifications, log lines, progress) after an event ID gap. This is a *delivery* guarantee over a byte stream. 2. **Protocol resumption** — the server is mid-`elicitation/create` (or mid-`sampling/createMessage`) and is *blocked waiting for a `elicitation/response` correlated by `id`*. This is a *request/response correlation* guarantee over a logical channel. The boundary failure is this: a dropped SSE leg can be transparently reattached at the transport layer while the outstanding elicitation request is *silently orphaned at the protocol layer*. The client believes it has resumed; the server believes it is still awaiting a response whose `id` will never arrive on the new stream because the client never saw the original request (it was emitted during the gap) and the server does not re-emit it on replay — replays only carry events with sequence IDs, and a server-push *request* is not an event, it is a request on the reverse channel. ## What Was Observed Reproduction trace, single tool call with a mid-flight elicitation: 1. Client POSTs `tools/call` for a tool that will ask the user to confirm a destructive action. Server returns `202 Accepted` with `Mcp-Session-Id: S`. Client opens `GET /mcp` with `Accept: text/event-stream` and `Mcp-Session-Id: S`. 2. Server begins streaming progress events with monotonically increasing `id: 1, 2, 3`. Client records `lastEventId=3`. 3. At the moment the tool reaches its confirmation point, the server emits `elicitation/create` with `id: 7` on the SSE stream **but the network leg drops before the client's reader processes it**. The server's write succeeds locally (kernel buffer), so the server considers the request *sent* and transitions its internal state to `AWAITING_ELICITATION(id=7)`. 4. Client reconnects `GET /mcp` with `Last-Event-ID: 3`. Server's replay buffer contains events `4, 5, 6` (progress), none of which is the elicitation request — **requests are not in the replay buffer because they were never assigned an event sequence number**. The elicitation `id: 7` is not replayed. 5. Client is now attached, sees progress events 4–6, and waits. Server waits for `elicitation/response` for `id: 7`. Both parties are live, both are waiting, neither will move. The tool call hangs until the server's per-request timeout fires (often 30–300s), at which point the server returns a tool error that the client attributes to the *tool*, not to a lost elicitation. 6. Worse variant: the client, seeing no pending elicitation and assuming the tool is purely server-driven, sends a *second* `tools/call` for the same logical operation. The server now has two concurrent tool invocations, one pinned on the orphaned `id: 7`, one live. Duplicate side effects. The observable symptom is not a crash. It is a **latency cliff plus a phantom duplicate**, which is why it survives most test suites. ## Condition of Validity The failure requires all of the following to hold simultaneously; remove any one and the symptom disappears: - **Server-push elicitation over the SSE leg** (not over the POST response body). If elicitation is delivered synchronously in the POST response, there is no gap to fall into. - **A transport-layer reconnect that is silent to the application layer.** The client's transport reconnects and replays by `Last-Event-ID` without surfacing to the agent runtime that "we may have missed a reverse-channel request." - **No server-side re-emission of outstanding requests on stream reattach.** The server treats elicitation as fire-and-forget-once over the stream rather than as a request with an at-least-once delivery obligation. - **A client that does not proactively reconcile its outstanding-request set on reconnect.** If the client, on every SSE (re)attach, sends a `notifications/initialized`-style resync or queries pending server requests, the orphan is caught. The condition is *most* likely when the elicitation window is long (human-in-the-loop confirmation) because the gap window scales with human think-time, and when the SSE leg is behind a proxy with an idle timeout (typical 60s) that fires precisely during the human pause. ## Decision Boundary The architectural invariant that must be enforced: > **Any server-push request that blocks the server's protocol state machine MUST be recoverable by `id` after transport reconnect, independent of the event replay buffer.** Two admissible implementations, and one inadmissible one: - **Admissible A — replayable requests.** Assign elicitation requests a sequence number in the same monotonic space as events, and place them in the replay buffer. On `Last-Event-ID` reattach, the server re-emits any request whose response has not arrived and whose sequence number is `> Last-Event-ID`. This makes transport resumption *imply* protocol resumption. Cost: the replay buffer must be response-aware, not just event-aware. - **Admissible B — explicit resync handshake.** On every SSE (re)attach, the client issues `notifications/stream_resumed` carrying its `lastEventId` and the set of `request_id`s it currently believes are outstanding. The server replies with the diff: any outstanding request whose `id` is not in the client's set is re-emitted. This pushes the reconciliation burden to an explicit protocol step. - **Inadmissible — replay-by-event-id only.** Assuming that reattaching the stream restores the logical channel. This is the exact conflation that produces the orphan. The decision boundary for the agent runtime is: *if the transport reports a reconnect, the agent MUST NOT assume its outstanding-request set is unchanged.* A reconnect is a state-divergence event, not a transparent retry. ## Operational Effect Downstream consequences an agent must plan for: - **Phantom tool timeout.** The tool error the client eventually sees is a *timeout attributed to the tool*, but the root cause is an orphaned elicitation. Retrying the tool re-asks the elicitation and may double-execute side effects. The correct recovery is to *cancel* the prior invocation by `id` before retrying, not to retry blind. - **Human-answer loss.** In HITL flows, the human's answer to the orphaned elicitation is never solicited, so the agent proceeds on a default or blocks. If the default is "proceed," a destructive action may execute without the intended confirmation. This is a safety-relevant, not merely a liveness, failure. - **Session drift.** Because the server's state machine is pinned on `id: 7`, any *new* elicitation the server tries to emit may be queued behind the blocked one (depending on server concurrency model), so a subsequent unrelated confirmation silently never appears — the client sees the second tool call hang for a different reason than the first. - **Bounded guardrail.** Enforce (i) a client-side `pending_server_requests` set populated on every received request and *reconciled* on every stream reattach, (ii) a server-side replay buffer that includes un-responded requests, and (iii) a hard rule that a reattach with a non-empty outstanding set triggers an explicit resync round-trip before any further tool calls are issued on that session. ```python import time from dataclasses import dataclass, field from typing import Dict, Optional, Set class OrphanedElicitationError(RuntimeError): """Raised when a streamable-session reattach completes but the client's outstanding server-push request set diverges from the server's.""" pass @dataclass class StreamState: last_event_id: int = 0 # request_id -> sent_at; populated when the client *receives* a server-push request pending_server_requests: Dict[str, float] = field(default_factory=dict) class StreamableSession: def __init__(self, session_id: str): self.session_id = session_id self.state = StreamState() def on_server_push_request(self, request_id: str) -> None: self.state.pending_server_requests[request_id] = time.monotonic() def on_elicitation_response(self, request_id: str) -> None: self.state.pending_server_requests.pop(request_id, None) def on_event(self, event_id: int) -> None: if event_id <= self.state.last_event_id: return self.state.last_event_id = event_id def reattach(self, server_outstanding: Set[str], resync_ok: bool) -> None: # Transport reconnect is NOT protocol resumption. Reconcile explicitly. client_outstanding = set(self.state.pending_server_requests) orphaned_on_client = server_outstanding - client_outstanding # server awaits, client never saw orphaned_on_server = client_outstanding - server_outstanding # client awaits, server forgot if orphaned_on_client and not resync_ok: raise OrphanedElicitationError( f"session {self.session_id}: reattach would orphan " f"{sorted(orphaned_on_client)} (server awaiting, client never received); " f"refusing to proceed without explicit resync round-trip" ) if orphaned_on_server: raise OrphanedElicitationError( f"session {self.session_id}: client holds pending requests " f"{sorted(orphaned_on_server)} the server no longer tracks; " f"session state diverged — cancel and re-establish" ) # Only after a clean reconciliation may new tool calls proceed on this session. self.state.pending_server_requests = {rid: time.monotonic() for rid in server_outstanding} ```