{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-an-mcp-sse-to-websocket-upgrade-as-a-session-resumption-boundary-rather-than-a-transport-swap",
  "title": "Under what conditions must an instance treat an MCP SSE-to-WebSocket upgrade as a session-resumption boundary rather than a transport swap",
  "date_of_record": "2026 November 27",
  "scope": "Applies to MCP clients and servers that expose the HTTP-native transport with a `text/event-stream` (SSE) streaming leg and negotiate an in-place upgrade to WebSocket mid-session, where the client holds a resumption token (`Last-Event-ID` / `session_id`) issued before the upgrade. Does not apply to pure stdio transports, to fresh WebSocket sessions with no prior SSE leg, or to stateless one-shot request/response MCP deployments.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-sse-to-websocket-upgrade-as-a-session-resumption-boundary-rather-than-a-transport-swap.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-sse-to-websocket-upgrade-as-a-session-resumption-boundary-rather-than-a-transport-swap.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-an-mcp-sse-to-websocket-upgrade-as-a-session-resumption-boundary-rather-than-a-transport-swap.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2209,
    "python_slice_tokens": 456,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A transport upgrade is not a session continuation. When an MCP server accepts an `Upgrade: websocket` request on a connection that previously carried an SSE stream, it establishes a *new* framing layer, a *new* flow-control regime, and — critically — a *new* server-side dispatch context unless the server explicitly rehydrates the pre-upgrade session. The SSE...",
    "what_was_observed": "A client agent issued `tools/call` for a long-running operation, received `202 Accepted` with `Mcp-Session-Id: s-7f3a` and an SSE stream. The server emitted `event: message` frames with `id: 41`, `id: 42` (a progress notification), then the client's HTTP/2 connection was reaped by an intermediate load balancer at the 60s idle boundary while the tool was still executing. The client reconnected with `Last-Event-ID: 42`...",
    "condition_of_validity": "The \"transport swap is safe\" assumption is valid only under the conjunction: - The server's replay buffer is keyed on `(session_id, last_event_id)` and is shared across *all* transport legs of that session, not per-connection. - Every event emitted on any leg carries a monotonically increasing `id` that the client can reconcile, including WebSocket frames (w...",
    "decision_boundary": "The client agent must decide, on receiving `101 Switching Protocols` in response to a resumption request carrying `Last-Event-ID: k`: - **Treat as continuation** (do not reset watermark) iff the first frame(s) on the WS leg are sequenced and the highest observed `id` equals `k+1` with no gaps, *and* the server advertised `replay_drained: true` in an upgrade-...",
    "operational_effect": "The practical consequence is that an agent resuming across an upgrade must run in *replay-verification mode* until the watermark is re-established. Concretely: buffer all post-upgrade events, do not dispatch tool results to the executor, and do not advance `Last-Event-ID` until a sequenced frame confirms continuity. If no sequenced frame arrives within a bou..."
  },
  "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": "7cc45a8df2498a8eeb4a8a270ccd2027cb0cfc403c402bef866466de8d1fca82",
    "verified_classes": [
      "ResumptionBoundaryError",
      "Event",
      "SessionLog",
      "UpgradeResumptionGuard"
    ],
    "verified_functions": [
      "append",
      "after",
      "__init__",
      "on_upgrade_accept",
      "on_frame",
      "_consume_sequenced",
      "assert_drained"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ResumptionBoundaryError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
