# Why does an instance lose elicitation warrants across SSE resumption behind a stateless MCP gateway? **Date of Record:** 2026 December 1 **Scope:** Applies to MCP servers exposing HTTP-native streaming (SSE) transport with `Last-Event-ID` resumption, fronted by a stateless reverse-proxy or API gateway, where the server may issue `elicitation/create` requests that require a correlated client response. Does not apply to stdio transport, to stateful session-affinity gateways that pin the SSE connection to a single backend, or to servers that only emit server-push notifications without response correlation. ## Core Distinction The distinction that matters is between **stream continuity** and **warrant continuity**. An SSE stream can resume cleanly—`Last-Event-ID` honored, missed events replayed, the client's `EventSource`/fetch reader reattached with no gap in the byte stream—while the *authorization to respond to a server-initiated elicitation* has silently expired. The stream is a transport-level artifact; the elicitation warrant is a protocol-level, stateful capability bound to a specific session incarnation on a specific backend process. A stateless gateway treats resumption as "reconnect the socket," but the MCP session semantics require "rebind the capability." These diverge exactly when the backend that issued the elicitation is not the backend that receives the response. The non-obvious part: the failure is invisible at the transport layer. Every SSE frame replays, every `id:` field is monotonic, the client's `Last-Event-ID` is accepted with `200 OK`. The elicitation dies not because the stream broke, but because the response arrives at a process that never minted the `requestId → elicitation` binding. ## What Was Observed A gateway load-balances across N=4 server instances (`mcp-server-a..d`), each holding an in-memory map `pending_elicitations: dict[request_id, ElicitationContext]`. The client holds a long-lived SSE `GET /mcp/stream` with `Accept: text/event-stream`. Mid-stream, the server emits: ``` id: 4821 event: elicitation/create data: {"jsonrpc":"2.0","id":"elicit-7f3a","method":"elicitation/create", "params":{"message":"Confirm deletion of 1,204 rows?", "requestedSchema":{"type":"object","properties":{"confirm":{"type":"boolean"}}}}} ``` The client's reader is fine. The gateway's idle timeout (default 60s) fires because the server is *waiting on the human/agent to answer*—no bytes flow—and the gateway drops the upstream socket. The client reconnects with `Last-Event-ID: 4821`. The gateway, stateless, routes the new `GET /mcp/stream` to `mcp-server-c`. Server C has no `elicit-7f3a` in its map. It replays events ≥ 4822 from a shared event log (if any) or from nothing, and the replayed `elicitation/create` frame is re-emitted—but now the client's `POST /mcp/message` carrying `{"id":"elicit-7f3a","result":{"confirm":true}}` lands on `mcp-server-b` (round-robin), which also has no binding, and returns `-32602 Invalid params: unknown request id` or, worse, silently 202s and the elicitation is orphaned. Observed trace across three runs: | Run | Reconnect target | `elicit-7f3a` present | Client POST target | Outcome | |-----|------------------|-----------------------|--------------------|---------| | 1 | server-c | no | server-b | `-32602`, elicitation orphaned | | 2 | server-a | no | server-a | 202, no handler, silent drop | | 3 | server-b (original) | yes | server-b | resolved, but replay duplicated frame 4821 → client saw two elicitations | Run 3 shows the second boundary: even on the "lucky" same-instance path, replaying the elicitation frame causes double-elicitation because the client cannot distinguish a *replayed* elicitation from a *new* one—`requestId` is reused verbatim in the replay. ## Condition of Validity The invariant that must hold for resumable SSE + elicitation to be correct: > For every `elicitation/create` frame with `requestId R` emitted on stream incarnation `S`, the response `R` must be delivered to a process whose `pending_elicitations` contains `R`, exactly once, and any replayed `R` on a resumed stream must be idempotent at the client (deduplicated by `(R, incarnation)` not by `R` alone). This is violated whenever any of the following holds: 1. **Stateless routing between stream and message endpoints.** The gateway does not pin `GET /stream` and `POST /message` to the same backend. This is the primary trigger. 2. **Idle-timeout severance during elicitation wait.** Elicitation is inherently a long-latency, zero-byte-flow operation; any gateway idle timeout shorter than the human/agent response budget severs the upstream. 3. **Replay without incarnation tagging.** `Last-Event-ID` replay re-emits the elicitation frame with the same `requestId`, and the client has no `incarnation` field to dedupe on. 4. **Non-durable pending map.** `pending_elicitations` is process-local; a backend restart or scale-down loses it while the stream resumes against a sibling. The condition of validity is *not* "the stream stays up." It is "the elicitation binding survives the transport discontinuity and the response is routed to the binding's owner." ## Decision Boundary The architectural fork is between two defensible designs, and the failure lives in the middle where teams land accidentally: **Design A — Session affinity (stateful gateway).** Pin the MCP session to one backend via `Mcp-Session-Id` header; route both stream and message on that key. Elicitation bindings stay process-local and correct. Cost: no horizontal scale-out of a single session, drain-on-redeploy required. Valid *only if* the gateway enforces affinity and the backend drains gracefully; a rolling deploy that kills the pinned backend mid-elicitation still orphans it unless the binding is externalized. **Design B — Externalized warrant store (stateless gateway, correct).** Move `pending_elicitations` out of process into a shared store keyed by `(Mcp-Session-Id, requestId, incarnation)`. On reconnect, the new backend reads the binding, and the response POST resolves against the store regardless of which instance receives it. The elicitation frame carries an `incarnation` field so replayed frames are deduplicable client-side. Cost: a network hop and a consistency requirement on the store; the store must be read-your-writes for the response to find the binding. **The invalid middle:** stateless gateway + process-local map + `Last-Event-ID` replay + no incarnation tag. This is the default that emerges when a team adds SSE to an existing stateless HTTP service and assumes resumption is a transport concern. It passes smoke tests (single instance, fast elicitation) and fails under load-balancing, idle timeout, or redeploy. The decision boundary in practice: if `pending_elicitations` is process-local, you *must* have affinity; if you have no affinity, you *must* externalize the map and tag incarnations. There is no third option that is correct. ## Operational Effect The downstream effects are subtle and misattributed: - **Silent orphaning.** The elicitation is neither resolved nor rejected; the server's tool call that depended on it hangs until its own timeout, and the agent's reasoning loop stalls on a tool result that never arrives. The agent does not see "elicitation failed"—it sees a tool call that never returns, and may retry the *entire* tool, re-triggering the side effect the elicitation was meant to gate (e.g., re-issuing the deletion). - **Double-elicitation on replay.** The client (often a human-in-the-loop UI or an agent policy) receives two identical confirmation prompts for one logical action. If the policy auto-confirms, it confirms twice; if a human answers, the second prompt is confusing and the first answer may be discarded. - **Warrant confusion across sessions.** If `requestId` is a monotonic counter rather than a UUID, a new session on a reused backend can collide with a stale binding and resolve the *wrong* elicitation—a correctness bug, not just a liveness one. - **Retry amplification.** Because the failure manifests as a hung tool call, agent retry logic re-invokes the tool, each invocation minting a new `requestId` and a new binding, multiplying pending state and, in the worst case, replaying the gated side effect. The guardrail is a hard invariant enforced at the protocol layer: elicitation responses must be rejected (not silently dropped) when the binding is absent, and the client must treat a replayed elicitation frame with an already-answered `(requestId, incarnation)` as a no-op. The following reference implementation encodes both the binding-ownership check and the incarnation dedupe, raising on the exact conditions that produce the silent-orphan and double-elicitation failures. ```python import time from dataclasses import dataclass, field from typing import Optional class ElicitationWarrantError(RuntimeError): """Raised when an elicitation response cannot be bound to a live warrant.""" pass @dataclass class ElicitationContext: request_id: str incarnation: int session_id: str created_at: float resolved: bool = False @dataclass class WarrantStore: """Externalized pending_elicitations keyed by (session_id, request_id, incarnation).""" _bindings: dict[tuple[str, str, int], ElicitationContext] = field(default_factory=dict) _answered: set[tuple[str, str, int]] = field(default_factory=set) def mint(self, session_id: str, request_id: str, incarnation: int) -> ElicitationContext: key = (session_id, request_id, incarnation) if key in self._bindings: raise ElicitationWarrantError( f"duplicate mint for {key}; request_id reuse across incarnations" ) ctx = ElicitationContext(request_id, incarnation, session_id, time.time()) self._bindings[key] = ctx return ctx def resolve(self, session_id: str, request_id: str, incarnation: int) -> ElicitationContext: key = (session_id, request_id, incarnation) ctx: Optional[ElicitationContext] = self._bindings.get(key) if ctx is None: # The exact stateless-gateway failure: response landed on a backend # that never minted the binding, or the binding was lost on redeploy. raise ElicitationWarrantError( f"no live warrant for {key}; response orphaned " f"(stateless routing or lost pending map)" ) if key in self._answered: # Replay after SSE resumption re-emitted the frame; treat as idempotent no-op. raise ElicitationWarrantError( f"warrant {key} already answered; replayed elicitation must be deduped" ) self._answered.add(key) ctx.resolved = True return ctx def handle_elicitation_response( store: WarrantStore, session_id: str, request_id: str, incarnation: int, payload: dict, ) -> None: """Entry point for POST /mcp/message carrying an elicitation response. Enforces the warrant-continuity invariant: the response must bind to a warrant minted on the same (session, request, incarnation) triple, and must be answered exactly once. """ try: ctx = store.resolve(session_id, request_id, incarnation) except ElicitationWarrantError as exc: # Do NOT silently 202. Surface the orphan so the agent can re-elicit # rather than hang the dependent tool call. raise ElicitationWarrantError( f"elicitation {request_id} could not be resolved on this backend: {exc}" ) from exc if not isinstance(payload.get("confirm"), bool): raise ElicitationWarrantError( f"elicitation {request_id} response violates requestedSchema" ) # Only here is the gated side effect permitted to proceed. _apply_confirmed_action(ctx, payload["confirm"]) def _apply_confirmed_action(ctx: ElicitationContext, confirm: bool) -> None: if not confirm: return # side effect elided return ```