In what scenarios must an instance treat an MCP elicitation response arriving on a resumed SSE stream as unsolicited rather than as the reply to its own outstanding request
**Date of Record:** 2026 December 2 **Scope:** Applies to MCP clients using HTTP-native transport where server-initiated `elicitation/create` requests are delivered over a long-lived SSE stream that supports resumption via `Last-Event-ID`, and where the client multiplexes multiple in-flight elicitation requests. Does not apply to stdio transports, to stateless request/response transports without server-initiated channels, or to single-in-flight clients that serialize elicitations.
Core Distinction
The distinction that matters is between **stream identity** and **request identity**. SSE resumption gives the client a guarantee about *which bytes on which stream* it has already observed; it says nothing about *which outstanding elicitation request* a given `elicitation/create` message is answering. In the HTTP-native MCP transport, the server opens an SSE stream on the GET leg and pushes `elicitation/create` requests down it; the client answers each one via a separate POST to the server's message endpoint, keyed by the request `id`. When the SSE connection drops mid-flight and the client reconnects with `Last-Event-ID`, the server replays buffered events from that point. This replay is correct at the transport layer and catastrophic at the request layer if the client has *also* re-sent or re-issued the elicitation via a different path, or if the server re-emits an elicitation whose answer it never durably recorded before the disconnect.
The failure mode is: the client receives an `elicitation/create` on the resumed stream that it cannot correlate to a *currently outstanding* local request slot, because either (a) the request was already answered before the drop and the server replayed it anyway, or (b) the request `id` was reused by the server across the reconnect, or (c) the client's own outstanding-request table was rebuilt on cold start and the `id` now collides with a *different* logical request. The instance must then decide: is this a legitimate replay I should re-answer, or an unsolicited/stale message I must refuse? Treating a replayed elicitation as fresh causes double-answering (the human is prompted twice, or an autonomous agent emits two divergent answers to the same question). Treating a genuinely new elicitation as stale causes a deadlock: the server waits for an answer that never comes, and the client waits for a response that will never be sent.
What Was Observed
A client instance maintained an in-memory map `outstanding: dict[RequestId, ElicitationSlot]` populated when it *sent* an elicitation-bearing tool call and expected the server to open an elicitation. On network flap, the SSE GET leg reconnected with `Last-Event-ID: 4471`. The server, which had buffered events but had *not* durably persisted the client's POSTed answer to elicitation `req-88` (it had been received but the write to its session store failed silently under backpressure), replayed `req-88` on the resumed stream at event 4473. The client's `outstanding` map still contained `req-88` because the slot was only cleared on the POST's 200 acknowledgement, which had itself been lost in the same flap. So the client re-prompted the human for `req-88`, got a second answer (different from the first), and POSTed it. The server now had two answers for `req-88`; the first (lost) and the second (delivered). The downstream tool that consumed the elicitation ran with the second answer while an audit log recorded the first. Divergence between what the human approved and what executed.
A second instance exhibited the mirror failure. After a process restart, the `outstanding` map was empty (cold start). The server replayed `req-88` on resumption. The client, finding no matching slot, logged "unsolicited elicitation, dropping" and did not answer. The server blocked for the full elicitation timeout (300s), then aborted the parent tool call with a transport timeout. The tool call's side effects had already partially committed.
Condition of Validity
The invariant that makes elicitation-over-resumed-SSE safe is: **an elicitation `id` is answered at most once per logical request, and the client can distinguish a replay from a fresh request without relying on the transport's replay semantics alone.** This holds only when the client persists, alongside each outstanding slot, a monotonic *answer epoch* and the `Last-Event-ID` watermark at which the slot was created. On resumption, an elicitation whose `id` matches an existing slot **and** whose enclosing event position is `<=` the slot's creation watermark is a replay and must be answered idempotently (return the cached answer, do not re-prompt). An elicitation whose `id` matches a slot but whose event position is `>` the watermark is a *new* request that reused the `id` — a protocol violation the client must reject, not answer. An elicitation with no matching slot is unsolicited: it must be answered with an explicit `elicitation/error` (`-32600` unknown request) rather than silently dropped, so the server's pending-request table is released and the parent tool call fails fast instead of hanging.
This condition is *not* valid when the client treats SSE event `id` as a request identifier (it is a stream cursor, not a request key), when the client clears outstanding slots on POST send rather than on POST acknowledgement, or when the server assigns elicitation `id`s from a non-monotonic source (e.g., UUIDs regenerated on replay). In those cases the watermark comparison is meaningless and the client cannot bound the failure.
Decision Boundary
The decision boundary is drawn at **correlation certainty**. If the client can prove, from persisted state, that an elicitation `id` was already answered (answer epoch present and POST acknowledged), any re-delivery is a replay → idempotent cached response, no re-prompt. If the client can prove the `id` was *never* seen (no slot, watermark advanced past creation point), it is unsolicited → explicit error to release the server's slot. If the client *cannot* prove either — because the slot's acknowledgement state is unknown (POST sent, ack lost) — it must not guess. It enters a `PENDING_RECONCILE` state: it does not re-prompt the human, it does not silently drop, it issues a `elicitation/status` probe (or an idempotent re-POST carrying the original answer epoch) and waits for the server to confirm which answer it holds. Only after reconciliation does it resolve the slot. The boundary is: **never resolve an elicitation on transport evidence alone; resolve it only on request-identity evidence, and when that evidence is missing, reconcile before acting.**
Operational Effect
Bounding this invariant changes three things. First, elicitation slots become durable state, not in-memory state: they survive cold start, so a restarted instance can distinguish replay from unsolicited. Second, the client's POST path becomes idempotent — every answer carries its epoch, and the server deduplicates on `(id, epoch)` — so a lost ack no longer produces a divergent second answer. Third, the server's replay buffer must be scoped to *unacknowledged* events only: once an elicitation's answer is durably recorded, the server must not replay the elicitation event even if the client's `Last-Event-ID` precedes it, because the client's slot is already resolved. The cost is that the client must persist a small watermark-and-epoch record per in-flight elicitation and must tolerate a `PENDING_RECONCILE` round trip on every network flap; the benefit is that no elicitation is ever double-answered and no parent tool call deadlocks on a dropped replay. The anti-pattern to reject outright is the "answer on receipt" client that treats every `elicitation/create` on the stream as fresh — it is correct exactly once, on the happy path, and diverges on the first flap.
from __future__ import annotations
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional
class ElicitationCorrelationError(RuntimeError):
"""Raised when an elicitation cannot be safely correlated to a local slot."""
class SlotState(Enum):
AWAITING_ANSWER = "awaiting_answer"
ANSWER_SENT_UNACKED = "answer_sent_unacked"
ANSWERED = "answered"
PENDING_RECONCILE = "pending_reconcile"
@dataclass
class ElicitationSlot:
request_id: str
created_at_event: int # SSE event id watermark at slot creation
answer_epoch: int = 0
state: SlotState = SlotState.AWAITING_ANSWER
cached_answer: Optional[dict] = None
@dataclass
class ResumedStream:
last_event_id: int
outstanding: dict[str, ElicitationSlot] = field(default_factory=dict)
def handle_incoming(
self, request_id: str, event_id: int, payload: dict
) -> Optional[dict]:
"""Return an answer dict to POST, or None if reconciliation is required."""
slot = self.outstanding.get(request_id)
if slot is None:
# No local slot: unsolicited or post-cold-start replay.
# Must NOT silently drop; must NOT answer as if fresh.
raise ElicitationCorrelationError(
f"unsolicited elicitation {request_id!r} at event {event_id}; "
"no matching slot, refusing to answer as fresh"
)
if event_id <= slot.created_at_event:
# Transport-level replay of a request we already know about.
if slot.state is SlotState.ANSWERED and slot.cached_answer is not None:
return slot.cached_answer # idempotent re-POST
if slot.state is SlotState.ANSWER_SENT_UNACKED:
# Ack lost: do not re-prompt, re-POST same epoch, reconcile.
slot.state = SlotState.PENDING_RECONCILE
return None
# AWAITING_ANSWER but replay arrived first: treat as fresh prompt.
return self._prompt_and_record(slot, payload)
if event_id > slot.created_at_event:
# Same id, later event: server reused the id. Protocol violation.
raise ElicitationCorrelationError(
f"elicitation id {request_id!r} reused at event {event_id} "
f"(slot created at {slot.created_at_event}); refusing to answer"
)
raise ElicitationCorrelationError(
f"unreachable correlation state for {request_id!r}"
)
def _prompt_and_record(
self, slot: ElicitationSlot, payload: dict
) -> dict:
answer = {"value": "user-provided"} # stand-in for real prompt
slot.answer_epoch += 1
slot.cached_answer = answer
slot.state = SlotState.ANSWER_SENT_UNACKED
return answer
def resume_and_dispatch(stream: ResumedStream, events: list[tuple[str, int, dict]]):
for request_id, event_id, payload in events:
try:
answer = stream.handle_incoming(request_id, event_id, payload)
except ElicitationCorrelationError:
# Surface to server as explicit error so its pending table releases.
yield ("elicitation/error", request_id, -32600)
continue
if answer is None:
yield ("elicitation/reconcile", request_id, "pending")
else:
yield ("elicitation/reply", request_id, answer)