{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-an-mcp-streamable-http-sse-to-websocket-upgrade-as-non-resumable-after-a-last-event-id-replay-gap",
  "title": "Under what conditions must an instance treat an MCP Streamable-HTTP SSE-to-WebSocket upgrade as non-resumable after a Last-Event-ID replay gap",
  "date_of_record": "2026 November 24",
  "scope": "Applies to MCP clients and servers negotiating a transport upgrade from HTTP+SSE (Streamable HTTP) to a WebSocket channel mid-session, where the server advertises `Last-Event-ID` resumability. Does not apply to pure WebSocket-first transports, stateless JSON-RPC over HTTP POST, or stdio transports.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-streamable-http-sse-to-websocket-upgrade-as-non-resumable-after-a-last-event-id-replay-gap.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-streamable-http-sse-to-websocket-upgrade-as-non-resumable-after-a-last-event-id-replay-gap.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-streamable-http-sse-to-websocket-upgrade-as-non-resumable-after-a-last-event-id-replay-gap.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1800,
    "python_slice_tokens": 286,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the SSE stream dropped.\" Drops are expected and resumable. The failure is that the *upgrade negotiation itself* consumes event-ID sequence space on the SSE leg while the WebSocket leg is being established, and the server's replay buffer is keyed to a cursor that the client believes it still owns but the server has already advanced past. T...",
    "what_was_observed": "A client agent issued `tools/call` for a multi-step filesystem operation. The server streamed partial results over SSE with monotonically increasing `id:` fields (`evt-1001` … `evt-1044`). At `evt-1044` the server emitted an `upgrade` control event and began the WebSocket handshake. During the handshake (measured 180–420 ms in the trace), the tool continued executing and the server emitted `evt-1045` through `evt-105...",
    "condition_of_validity": "A `Last-Event-ID` resume across an SSE→WebSocket upgrade is valid **if and only if** all three hold: 1. **Shared sequence domain.** The server's `hello` frame advertises a `high_water` equal to the client's `Last-Event-ID`, OR the server's replay buffer demonstrably contains every integer ID in `(last_seen, high_water]`. A `high_water` strictly greater than ...",
    "decision_boundary": "The boundary is drawn at the moment the client receives the `hello` frame, not at the moment the SSE leg drops. Concretely: - If `hello.high_water == client.last_seen_id` → resume is safe; continue on WebSocket. - If `hello.high_water > client.last_seen_id` **and** the resume response includes an explicit replayed-ID set covering the gap → resume is safe; pr...",
    "operational_effect": "The downstream effect is not a visible error but a *silent state divergence* that surfaces later as contradictory tool calls. Because the agent's local trace remains internally consistent (it saw `evt-1044`, it saw `resumed: true`, it saw silence, it concluded completion), no exception fires at the transport layer. The divergence manifests one or more reason..."
  },
  "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": "bf936ce23fadb39bd248f143add9dfef2886c655499b7badd9b6725506a77a42",
    "verified_classes": [
      "ResumeGapError"
    ],
    "verified_functions": [
      "validate_upgrade_resume"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ResumeGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
