# Where must an instance refuse to acknowledge an MCP resource subscription when HTTP/2 flow-control credit has been silently exhausted by a slow consumer **Date of Record:** 2026 December 3 **Scope:** Applies to MCP clients that hold `resources/subscribe` handles over HTTP/2 (or HTTP/2-over-TLS) transports where the server pushes `notifications/resources/updated` frames on the same stream-set as request/response traffic. Does not apply to stdio transports, WebSocket transports with application-level framing, or SSE-only fallbacks where flow control is delegated to TCP. ## Core Distinction The failure is not "the server sent too much data." The failure is that the *client acknowledged the subscription* (`resources/subscribe` returned a subscription ID) while the underlying HTTP/2 connection had no remaining outbound credit on the stream the notifications would flow through — and the acknowledgement was committed to the agent's episodic memory as a durable capability grant. The distinction that matters is between **subscription acceptance** (a protocol-level promise, held in the agent's state) and **subscription viability** (a transport-level property, held in the flow-control window). MCP's `resources/subscribe` response carries only the former. An agent that treats the two as equivalent will believe it has a live watch on a resource while every subsequent notification is buffered in the server's write queue, then either dropped on stream reset or replayed in a burst that saturates the client's context window the moment the consumer drains its queue. The invariant that holds in correct deployments: **a subscription ID is only valid while the HTTP/2 stream it was negotiated on has nonzero `SETTINGS_INITIAL_WINDOW_SIZE` headroom for at least one notification frame.** Violating this invariant does not produce a protocol error. It produces a silent divergence between what the agent thinks it can observe and what it actually observes. ## What Was Observed A research agent (instance A) subscribed to three MCP resources on the same HTTP/2 connection: a `log://run/events` stream, a `metrics://queue/depth` gauge, and a `doc://corpus/index` manifest. The transport negotiated a single connection with `MAX_CONCURRENT_STREAMS=100` and the default per-stream window of 65,535 bytes, plus a connection-level window of 1 MiB. The agent then entered a long tool-execution loop — a 40-step chain of `shell.exec` calls — that blocked the event loop servicing the HTTP/2 client for roughly 90 seconds. During that window: 1. The server pushed 2,847 `notifications/resources/updated` frames for `log://run/events`, each ~180 bytes. Total ≈ 512 KB. 2. The connection-level window (1 MiB) absorbed the first ~5,800 frames' worth of credit — but the *stream-level* window for the subscription stream was 65,535 bytes, exhausted after ~360 frames. 3. The server's HTTP/2 writer blocked on `WINDOW_UPDATE` for the stream. Its internal notification buffer for that subscription grew unbounded until a hard cap (implementation-defined, in this case 4 MB) tripped. 4. On cap trip, the server sent `RST_STREAM` with `ENHANCE_YOUR_CALM` on the subscription stream and *kept the subscription record alive* in its registry — because the MCP layer had no hook to the HTTP/2 stream reset. 5. The client, on resuming its event loop, saw the stream reset, tore down its local stream state, and logged a transport error. It did **not** invalidate the subscription ID in its memory store, because the subscription ID was a protocol-layer object and the reset was a transport-layer event. The agent's next reasoning step read its memory: "subscription `sub_7f3a` active on `log://run/events`." It then issued a `resources/read` on a derived URI expecting the log to be current. The read returned the state as of the reset — 89 seconds stale — with no error, because the resource itself was healthy; only the *notification channel* was dead. The agent proceeded to reason over a log that had silently stopped updating, and its subsequent 12 tool calls were predicated on a stale view of a queue that had in fact drained and refilled twice. The compound failure: **subscription liveness was inferred from protocol state, not transport state, and the two had diverged 89 seconds earlier without any signal the agent was instrumented to observe.** ## Condition of Validity The invariant "subscription ID ⇒ live notification channel" holds only under the conjunction: - The HTTP/2 stream carrying the subscription has a per-stream receive window sized for the *peak* notification burst rate, not the mean. For an agent that blocks its event loop for T seconds while a resource emits at rate R frames/sec of size S bytes, the required window is at least `R · T · S` minus whatever the server is willing to buffer. - The server maps `RST_STREAM` on a subscription stream to a subscription-invalidation event in the MCP layer, and emits a terminal `notifications/resources/updated` with a sentinel `closed` reason (or an equivalent out-of-band signal) before tearing down. - The client's memory store treats subscription IDs as *lease-bound* objects with a TTL and a heartbeat, not as indefinite grants. If any of these three fail, the subscription ID becomes a **zombie handle**: a capability the agent believes it holds, that the protocol layer will still accept reads against, but that no longer delivers updates. The agent cannot detect the zombie state through any MCP-native call, because `resources/read` succeeds (the resource is fine) and `resources/subscribe` on the same URI returns a *new* subscription ID without indicating the old one is dead. The only detection path is transport-layer instrumentation the MCP spec does not require. The boundary is sharp: below the window threshold, everything works and the failure is invisible in testing. Above it, the failure is silent and the agent's reasoning degrades in a way that looks like a model-quality problem (stale-context hallucination) rather than a transport problem. ## Decision Boundary The decision an agent runtime must make, on every `resources/subscribe` acknowledgement, is whether to **commit the subscription to durable memory** or to **hold it as a provisional lease pending transport confirmation**. The boundary condition is: *commit only if the transport reports a nonzero, verifiable flow-control headroom on the subscription stream AND the runtime has a heartbeat mechanism that can detect stream reset within a bounded interval.* Concretely, the runtime must refuse to commit when any of the following hold at acknowledgement time: - The HTTP/2 stream's `remote_settings.initial_window_size` is smaller than the resource's declared or observed peak frame size × expected burst depth. - The connection has no `PING`-based liveness probe configured (HTTP/2 `PING` frames are the only transport-native way to detect a half-dead connection before the next application write fails). - The runtime's event loop has a known blocking section (long tool calls, synchronous model inference) that exceeds the server's notification buffer drain time. When the runtime refuses to commit, it must **not** silently downgrade to polling without recording the downgrade. The correct behavior is to raise a structured error that the agent's planner can branch on — because a planner that believes it has a subscription and a planner that knows it has a poll-loop make different decisions about how much staleness it can tolerate. The inverse boundary also matters: a runtime that *over*-conservatively refuses every subscription degrades to polling and burns context on redundant reads. The threshold must be computed from observed frame sizes and observed event-loop blocking times, not set to a fixed conservative constant. A subscription to a low-rate gauge (`metrics://queue/depth` at 1 frame/5s) is safe at any window size; a subscription to a high-rate log stream is not. ## Operational Effect The downstream effect is a specific class of reasoning error: **the agent reasons over a frozen world-model while believing it is live.** This is distinguishable from ordinary staleness because the agent has positive evidence of liveness (a subscription ID it successfully obtained) that is *wrong*. It will not re-read the resource, because re-reading a subscribed resource is redundant by construction. It will not notice the gap, because the gap is in the notification channel, not in the resource. The compounding is severe in multi-step tool loops: each step's precondition is checked against the frozen view, each step's effect is computed against it, and the error accumulates until some downstream assertion fails — at which point the agent's diagnosis will point at the tool that failed, not at the subscription that died 90 seconds earlier. Post-mortems of this failure mode routinely misattribute it to model hallucination or tool flakiness. The guardrail is architectural, not prompt-level: subscription handles must be **first-class leased objects** in the agent's state store, with (a) a transport-liveness heartbeat, (b) a TTL shorter than the agent's maximum event-loop blocking time, and (c) an invalidation path that fires on `RST_STREAM` and on heartbeat timeout, marking the handle `STALE` and forcing the planner to either re-subscribe or downgrade to explicit polling before its next read of the resource. The planner must treat `STALE` handles as *unknown* rather than *current*, which is a different branch than *known-stale* — the agent does not know how far behind it is, only that it is behind. The following reference implementation encodes the refusal boundary. It is deliberately strict: it refuses to commit a subscription when headroom is unverifiable, and it raises rather than silently downgrading, so the planner is forced to make an explicit choice. ```python from __future__ import annotations import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class SubscriptionCommitError(RuntimeError): """Raised when a subscription acknowledgement cannot be durably committed because transport-level flow-control headroom is unverifiable or insufficient.""" class HandleState(Enum): PROVISIONAL = "provisional" # ack received, transport not yet confirmed LIVE = "live" # committed, heartbeat healthy STALE = "stale" # transport reset or heartbeat missed REFUSED = "refused" # never committed; planner must poll @dataclass class TransportView: """Snapshot of the HTTP/2 transport state at acknowledgement time.""" stream_initial_window_bytes: int connection_window_bytes: int observed_peak_frame_bytes: int observed_burst_depth: int # frames per second at peak event_loop_max_block_seconds: float ping_liveness_configured: bool server_buffer_cap_bytes: int @dataclass class SubscriptionLease: subscription_id: str resource_uri: str state: HandleState committed_at: Optional[float] = None ttl_seconds: float = 30.0 last_heartbeat: Optional[float] = None invalidation_reason: Optional[str] = None _history: list = field(default_factory=list) def mark_stale(self, reason: str) -> None: if self.state is HandleState.LIVE: self.state = HandleState.STALE self.invalidation_reason = reason self._history.append((time.monotonic(), reason)) def required_window_bytes(view: TransportView) -> int: """Bytes the stream window must hold to survive one max-block interval without the server tripping its buffer cap.""" return int( view.observed_peak_frame_bytes * view.observed_burst_depth * view.event_loop_max_block_seconds ) def commit_subscription( subscription_id: str, resource_uri: str, view: TransportView, ) -> SubscriptionLease: """Commit a subscription only if the transport can actually sustain it. Raises SubscriptionCommitError when the ack is a zombie-handle risk. """ lease = SubscriptionLease( subscription_id=subscription_id, resource_uri=resource_uri, state=HandleState.PROVISIONAL, ) # Invariant 1: per-stream window must hold a full max-block burst. need = required_window_bytes(view) if view.stream_initial_window_bytes < need: lease.state = HandleState.REFUSED raise SubscriptionCommitError( f"stream window {view.stream_initial_window_bytes}B < required " f"{need}B for {resource_uri} at peak " f"{view.observed_peak_frame_bytes}B x {view.observed_burst_depth}/s " f"over {view.event_loop_max_block_seconds}s block; " f"refusing to commit {subscription_id}" ) # Invariant 2: server buffer must not trip before the window drains. if view.server_buffer_cap_bytes < need: lease.state = HandleState.REFUSED raise SubscriptionCommitError( f"server buffer cap {view.server_buffer_cap_bytes}B < required " f"{need}B; server will RST_STREAM before client drains" ) # Invariant 3: without PING liveness, a half-dead connection is undetectable. if not view.ping_liveness_configured: lease.state = HandleState.REFUSED raise SubscriptionCommitError( f"no HTTP/2 PING liveness probe configured; cannot detect " f"RST_STREAM on {subscription_id} within bounded interval" ) lease.state = HandleState.LIVE lease.committed_at = time.monotonic() lease.last_heartbeat = lease.committed_at return lease def heartbeat(lease: SubscriptionLease, now: Optional[float] = None) -> None: """Called on each successful PING ack or notification receipt.""" if lease.state is not HandleState.LIVE: raise SubscriptionCommitError( f"heartbeat on non-live lease {lease.subscription_id} " f"in state {lease.state.value}" ) lease.last_heartbeat = now if now is not None else time.monotonic() def check_lease(lease: SubscriptionLease, now: Optional[float] = None) -> HandleState: """Planner must call this before any read that assumes freshness.""" t = now if now is not None else time.monotonic() if lease.state is HandleState.LIVE and lease.last_heartbeat is not None: if t - lease.last_heartbeat > lease.ttl_seconds: lease.mark_stale("heartbeat_ttl_exceeded") return lease.state def on_stream_reset(lease: SubscriptionLease, error_code: str) -> None: """Transport layer must call this on RST_STREAM for the subscription stream.""" lease.mark_stale(f"rst_stream:{error_code}") ```