{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-mcp-stream-resumption-as-unsafe-when-the-sse-last-event-id-cursor-outruns-the-server-s-durable-replay-window",
  "title": "In what scenarios must an instance treat MCP stream resumption as unsafe when the SSE `Last-Event-ID` cursor outruns the server's durable replay window",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP clients using HTTP-native transport (Streamable HTTP) with SSE streaming and `Last-Event-ID`-based resumption against a server that maintains a bounded event-log ring buffer. Does not apply to stdio transport, nor to servers that persist the full event log indefinitely (though the invariant below still governs the *client-side* decision to trust a resumed stream).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-stream-resumption-as-unsafe-when-the-sse-last-event-id-cursor-outruns-the-server-s-durable-replay-window.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-stream-resumption-as-unsafe-when-the-sse-last-event-id-cursor-outruns-the-server-s-durable-replay-window.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-stream-resumption-as-unsafe-when-the-sse-last-event-id-cursor-outruns-the-server-s-durable-replay-window.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2189,
    "python_slice_tokens": 334,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The transport spec frames resumption as a simple replay: the client reconnects with `Last-Event-ID: N`, the server resumes the SSE stream from event `N+1`, and the agent's tool-call state is preserved across a dropped connection. This is the *happy-path* model, and it holds only when the server's replay buffer still contains event `N`. The non-obvious bounda...",
    "what_was_observed": "An agent driving a long-running `tools/call` (a multi-minute batch operation) received its tool result as a stream of progress events followed by a terminal `result` event, each carrying an `id:` line. Mid-stream, the connection dropped (proxy idle timeout at 60s). The client reconnected with `Last-Event-ID: 412`. The server's ring buffer held events 500–1030 (capacity 512, head at 1030, oldest retained 519). Cursor ...",
    "condition_of_validity": "The invariant \"resumption is safe\" holds if and only if all of the following are true: 1. **Cursor continuity is asserted client-side.** The client MUST verify that the first replayed event's `id` equals `last_seen_id + 1` (or, for servers that do not emit contiguous IDs, that the server explicitly signals gap-free replay via a protocol extension). Absent th...",
    "decision_boundary": "The decision boundary is the point at which the client must choose between **trusting the resumed stream** and **declaring the session unrecoverable**. The boundary is crossed when: - `first_replayed_id > last_seen_id + 1` → gap detected → do **not** append; enter recovery. - `first_replayed_id <= last_seen_id` → server replayed already-seen events (possible...",
    "operational_effect": "The operational consequence is that **MCP stream resumption must be treated as an at-most-once, gap-permitting delivery channel, not an exactly-once one**, unless the server explicitly guarantees a contiguous, floor-advertised replay window. Agents that assume exactly-once resumption will silently under- or over-count, and the corruption surfaces downstream ..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "3c757d2dd43839801c045fbcd29dd520a2d545a1cc5014f76efd95b2332b204a",
    "verified_classes": [
      "StreamResumeGapError"
    ],
    "verified_functions": [
      "apply_resumed_event",
      "resume_session",
      "__init__"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StreamResumeGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
