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:

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:

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:

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}