# What structural signals indicate an MCP elicitation request has been orphaned by a reconnecting client: the lost-elicitation-ID invariant in human-in-the-loop tool authorization **Date of Record:** 2026 November 29 **Scope:** Applies to MCP (Model Context Protocol) servers that gate tool execution behind human-in-the-loop authorization elicitations, where the client may disconnect, reconnect, or re-instantiate a session while an elicitation is pending. Does not cover consent flows where the authorization decision is synchronous within a single uninterrupted transport connection, nor non-MCP approval mechanisms. ## Core Distinction The failure is not "the human said no" and it is not "the human never answered." It is a third state that most MCP server implementations do not model: **the elicitation was answered, but the answer can no longer be correlated to the tool call that requested it.** A human-in-the-loop authorization is a two-phase protocol disguised as a single request. The server emits an elicitation carrying an identifier, blocks the tool call on that identifier, and resumes when a response arrives. The invariant that makes this safe is: > For every pending tool call blocked on an elicitation, there exists exactly one live correlation between the elicitation ID, the blocked tool invocation, and the transport session that will receive the decision. MCP's elicitation primitive is session-scoped. The `elicitation/create` request is delivered over the same transport channel as the tool call, and the response is expected on that channel. When the client reconnects — because a laptop lid closed, a network path rotated, a gateway recycled the SSE stream, or the agent host restarted — the server's transport binding is severed, but the *pending elicitation record inside the server is not*. The server typically still holds the blocked coroutine, the tool-call frame, and the elicitation ID. The reconnected client, however, has no memory of the elicitation unless the server re-announces it, and the client's own UI state that rendered the approval prompt is gone. The correlation is now half-alive: the server waits on an ID that the client will never answer, while the client may present a *new* approval prompt for a *retried* tool call, generating a second elicitation ID for the same logical action. The non-obvious consequence: the dangerous state is not a hang. A hang is observable and eventually times out. The dangerous state is **duplicate authorization** — two elicitation IDs, one human decision rendered twice, one tool executed once or twice depending on which ID the server resumes on. The structural signal that distinguishes an orphaned elicitation from a merely slow one is not elapsed time. It is the **divergence between the server's pending-elicitation set and the client's renderable-elicitation set**, observable only if the server tracks transport-generation alongside elicitation ID. ## What Was Observed A filesystem-write tool gated on human approval, exercised through an MCP client that maintains a persistent session with automatic reconnect. The server implemented elicitation as: generate `elicitation_id`, store `{elicitation_id → (tool_call_frame, asyncio.Event)}`, emit `elicitation/create`, `await event.wait()`, then execute or reject. Trace of the failure: 1. Agent issues `write_file` on a sensitive path. Server creates elicitation `e-4417`, stores the blocked frame, emits the request over transport generation `g-3`. 2. Human is presented the approval prompt. Before responding, the client's SSE stream drops (transport generation rotates to `g-4`). The client reconnects and re-initializes the session. 3. The client's UI, on reconnect, discards its pending-prompt state — it has no record of `e-4417`. The server still holds `e-4417` blocked on its event, bound to `g-3`. 4. The agent, seeing no progress on the tool call, retries `write_file` after its own timeout. Server creates a *second* elicitation `e-4418` for the same logical write, over `g-4`. 5. Human, now seeing a fresh prompt, approves. Response for `e-4418` arrives on `g-4`. Server executes the write, resumes the `e-4418` frame. 6. `e-4417` remains blocked forever on `g-3`. Its event is never set. The original tool-call frame is never resumed and never cancelled. Two distinct defects surfaced. First, the orphaned `e-4417` leaked a blocked coroutine and a retained tool-call frame indefinitely — a slow resource leak that also meant the *original* tool call never returned a result to the agent, so the agent's view of the operation was permanently indeterminate. Second, and more serious: if the human had approved on the *reconnected* prompt and the server had, on some code path, resumed the *first* matching `write_file` frame rather than the ID-matched one, the write would have executed against a frame whose authorization the human never saw in its current context. The correlation must be by elicitation ID, never by tool name or argument hash, because argument-hash matching silently collapses `e-4417` and `e-4418` into one authorization and reintroduces the duplicate-execution hazard. The structural signals that, in retrospect, cleanly identified the orphan were: (a) `e-4417.transport_generation = g-3` while the live session generation was `g-4`; (b) the client never sent any message referencing `e-4417` after reconnect; (c) the server's pending set contained an ID the client could not possibly render. None of these are visible from timing alone. ## Condition of Validity The orphaned-elicitation hazard is well-defined only under these conditions, and the guardrails below are only sound when they hold: - **Elicitations are session-scoped and transport-bound.** If the protocol carried elicitation state in a durable, resumable form (a resumable session token that the client replays on reconnect), the orphan could be re-announced rather than abandoned. The hazard is specific to transports where reconnect yields a *new* logical session with no elicitation replay. - **The server, not the client, owns the pending-elicitation record.** If the client owned the block and merely polled the server, a reconnect would naturally cancel the client-side wait. The hazard requires server-side blocking. - **Retries are possible.** If the agent never retried a stalled tool call, the orphan would be a pure leak, not a duplicate-authorization risk. Agent retry-on-timeout is what converts a leak into a correctness defect. - **Correlation is by ID, not by content.** The moment a server "helpfully" matches a late response to a pending request by tool name or argument similarity, the invariant is already violated and the guardrails below cannot recover it. When any of these fail to hold — e.g., a transport with durable elicitation replay — the specific remediation changes, though the underlying invariant (one live correlation per blocked call) remains the thing to protect. ## Decision Boundary The operational decision is: **on transport-generation change, what does the server do with pending elicitations bound to the dead generation?** The boundary between correct and incorrect handling is drawn by whether the server can prove the client still holds the elicitation. It cannot, in general, because reconnect does not replay client UI state. Therefore the only sound default is: - **Fail closed on generation change.** Any elicitation whose `transport_generation` no longer matches the live session generation is transitioned to `ORPHANED`, its blocked frame is resumed with an explicit *authorization-void* error (not a timeout, not a silent drop), and the tool call is *not* executed. - **Never re-bind an orphaned elicitation to a new generation.** Re-binding assumes the human's earlier context transfers; it does not, and it re-opens duplicate execution. - **Require a fresh elicitation for any retry.** The retry gets a new ID; the human sees a new prompt in their current context; the correlation is clean. - **Emit a distinguishable error to the agent** so it does not interpret the void as "denied" (which would suppress legitimate retries) or as "succeeded" (which would be a lie about a write that never happened). The boundary is *not* "time out after N seconds." A timeout conflates slow-human with orphaned-elicitation and will either cut off a genuinely deliberating human or, worse, fire after the human has already answered on the old generation, racing the resume. Generation-change is the correct trigger because it is a structural fact about correlation, not a heuristic about latency. ## Operational Effect With fail-closed-on-generation-change and ID-only correlation enforced, the observed system's behavior changed in three measurable ways. Orphaned elicitations stopped leaking: every generation rotation drained the pending set, and blocked frames were resumed with `ElicitationOrphaned` errors that the agent could distinguish from denial. Duplicate authorization became impossible by construction, because a retry always carried a new ID and the old ID could never be resumed. And the agent's indeterminate-wait problem disappeared, because the void error returned promptly on reconnect rather than hanging until an unrelated timeout. The residual cost is human friction: a reconnect during deliberation forces a re-prompt. This is the correct trade. The alternative — silently trusting that the human's approval, rendered in a dead session, still authorizes a tool call in a live one — is exactly the class of continuity violation that human-in-the-loop authorization exists to prevent. The invariant is not "the human approved something." It is "the human approved *this* call, in *this* session, and the server can prove the correlation." ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Dict class ElicitationOrphaned(RuntimeError): """Raised when a pending elicitation's transport generation is dead. This is deliberately NOT a denial and NOT a timeout. It signals that the correlation between the elicitation ID, the blocked tool call, and the live transport session has been severed, so the authorization is void and the tool MUST NOT execute. The agent should treat this as "retry with a fresh elicitation," never as "human said no." """ class ElicitationState(Enum): PENDING = "pending" RESOLVED = "resolved" ORPHANED = "orphaned" @dataclass class PendingElicitation: elicitation_id: str transport_generation: int tool_name: str state: ElicitationState = ElicitationState.PENDING @dataclass class ElicitationRegistry: live_generation: int pending: Dict[str, PendingElicitation] = field(default_factory=dict) def register(self, elicitation_id: str, tool_name: str) -> PendingElicitation: rec = PendingElicitation( elicitation_id=elicitation_id, transport_generation=self.live_generation, tool_name=tool_name, ) self.pending[elicitation_id] = rec return rec def on_transport_rotate(self, new_generation: int) -> list[str]: """Drain orphans on reconnect. Returns IDs voided by this rotation.""" self.live_generation = new_generation orphaned: list[str] = [] for eid, rec in list(self.pending.items()): if rec.state is ElicitationState.PENDING and rec.transport_generation != new_generation: rec.state = ElicitationState.ORPHANED orphaned.append(eid) return orphaned def resolve(self, elicitation_id: str, approved: bool) -> bool: """Correlate a response strictly by ID and live generation. Content-based matching (tool name, arg hash) is forbidden: it silently collapses a retried elicitation onto an orphaned one and reintroduces duplicate authorization. """ rec = self.pending.get(elicitation_id) if rec is None: raise ElicitationOrphaned( f"response for unknown elicitation {elicitation_id!r}; " "no live correlation exists" ) if rec.state is ElicitationState.ORPHANED: raise ElicitationOrphaned( f"elicitation {elicitation_id!r} was orphaned at generation " f"{rec.transport_generation}; live generation is " f"{self.live_generation}" ) if rec.transport_generation != self.live_generation: rec.state = ElicitationState.ORPHANED raise ElicitationOrphaned( f"elicitation {elicitation_id!r} bound to generation " f"{rec.transport_generation}, response arrived on " f"{self.live_generation}; authorization void" ) rec.state = ElicitationState.RESOLVED return approved def authorize_tool_call( registry: ElicitationRegistry, elicitation_id: str, approved: bool, ) -> str: """Gate a tool call on a human decision, enforcing the ID+generation invariant.""" try: granted = registry.resolve(elicitation_id, approved) except ElicitationOrphaned as exc: # Fail closed: the tool does not run. Surface a distinguishable error # so the agent retries with a fresh elicitation rather than treating # this as a denial or a success. raise ElicitationOrphaned(str(exc)) from exc if not granted: return "denied" return "executed" ```