{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-abandon-sse-replay-state-when-an-mcp-http-native-transport-upgrades-to-websocket-mid-session",
  "title": "Under what conditions must an instance abandon SSE replay state when an MCP HTTP-native transport upgrades to WebSocket mid-session",
  "date_of_record": "2026 November 28",
  "scope": "Applies to MCP HTTP-native transports that begin a session over Server-Sent Events (`text/event-stream`) and negotiate an in-band upgrade to a WebSocket channel for the same logical session, where the client relies on `Last-Event-ID` for resumption after disconnect. Does not apply to pure-SSE sessions that never upgrade, nor to sessions where the server assigns a fresh session identifier on upgrade.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abandon-sse-replay-state-when-an-mcp-http-native-transport-upgrades-to-websocket-mid-session.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abandon-sse-replay-state-when-an-mcp-http-native-transport-upgrades-to-websocket-mid-session.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abandon-sse-replay-state-when-an-mcp-http-native-transport-upgrades-to-websocket-mid-session.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2041,
    "python_slice_tokens": 429,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the connection dropped.\" The failure is that the SSE `id:` cursor and the WebSocket frame sequence are **two independent monotonic namespaces that the transport spec does not reconcile**. A client that reconnects after a mid-upgrade drop will present a `Last-Event-ID` drawn from the SSE stream to a server that has already switched its out...",
    "what_was_observed": "A research agent executing a 14-step tool chain (web fetch → parse → summarize → write) over MCP HTTP-native transport. Step 6 (`parse`, a long-running tool call) triggered a server-side `101 Switching Protocols` upgrade because the response payload exceeded the SSE chunk budget and the server preferred binary frames. The client library accepted the upgrade, kept the same `Mcp-Session-Id` header, and continued readin...",
    "condition_of_validity": "The resume contract is only valid when **all three** hold simultaneously: 1. **Namespace continuity** — every outbound frame, regardless of transport, carries an identifier drawn from a single monotonically increasing sequence scoped to the session, and the server's replay buffer indexes on that sequence, not on transport-local counters. 2. **Cursor translat...",
    "decision_boundary": "An agent instance must abandon its SSE replay cursor and treat the session as **fresh-but-tainted** (requiring idempotency reconciliation) when *any* of the following is true: - It presented a `Last-Event-ID` and observed a replay whose first event is a **duplicate of an already-completed tool call** — this is the signature of a cross-namespace replay, not a...",
    "operational_effect": "The correct response is not \"reconnect harder.\" It is: on detecting a cross-namespace replay, the agent must (a) freeze the step state machine at the last *durably checkpointed* step, (b) mark all in-flight tool calls as `UNKNOWN_OUTCOME` rather than `FAILED`, and (c) re-drive them through an idempotency key derived from the logical step, not the transport e..."
  },
  "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": "75d2cc14ac412fb1c8ac6117e2e9257e9aa8986aaf698142baa36464855d2de7",
    "verified_classes": [
      "CrossNamespaceReplayError",
      "CallOutcome",
      "StepLedger"
    ],
    "verified_functions": [
      "resume_after_upgrade",
      "key",
      "record",
      "outcome"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CrossNamespaceReplayError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
