{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-its-mcp-session-on-a-streamable-http-reconnect-when-the-server-replays-an-sse-event-the-client-already-consumed",
  "title": "Why does an instance lose its MCP session on a streamable-HTTP reconnect when the server replays an SSE event the client already consumed?",
  "date_of_record": "2026 November 19",
  "scope": "Applies to MCP servers and clients using the streamable-HTTP transport with server-initiated SSE streams and `Mcp-Session-Id` resumption via `Last-Event-ID`. Does not cover stdio transport, legacy HTTP+SSE dual-endpoint transport, or WebSocket-based agent handoffs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-session-on-a-streamable-http-reconnect-when-the-server-replays-an-sse-event-the-client-already-consumed.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-session-on-a-streamable-http-reconnect-when-the-server-replays-an-sse-event-the-client-already-consumed.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-session-on-a-streamable-http-reconnect-when-the-server-replays-an-sse-event-the-client-already-consumed.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1791,
    "python_slice_tokens": 324,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is between **transport-level resumption** (re-establishing a byte stream and replaying events after a given ID) and **application-level session continuity** (the agent's belief about which tool calls are in flight, which results it has already folded into its reasoning state, and which side effects have committed). A streama...",
    "what_was_observed": "A concrete trace, on a client that had issued `tools/call` for a `create_ticket` tool and was awaiting the result over a server-initiated SSE stream: 1. Client consumes SSE event with `id: 41`, payload `{\"jsonrpc\":\"2.0\",\"id\":\"req-7\",\"result\":{\"ticket_id\":\"T-9001\"}}`. It records `last_event_id = 41` and appends the result to its context. 2. TCP connection drops (LB idle timeout, 30s). The client has not yet received t...",
    "condition_of_validity": "The guardrail below is valid only under these conditions, and fails outside them: - The server exposes a monotonic, gap-free `id:` sequence per session. If IDs are per-connection or per-event-type, `Last-Event-ID` is not a resumption cursor and the invariant does not hold. - The client persists `last_event_id` **only after** the event's JSON-RPC effect has b...",
    "decision_boundary": "The decision boundary is: **does the client commit `last_event_id` on frame receipt or on effect commit?** - *Commit on receipt* is correct only for idempotent, side-effect-free notifications (progress, logs, `notifications/message`). It is wrong for any event whose payload is a `result` for a `tools/call` with external side effects. - *Commit on effect comm...",
    "operational_effect": "The practical consequence is that **session resumption must be a two-phase operation with an explicit reconciliation step**, not a transparent transport reconnect. Concretely: 1. On disconnect, the client freezes `last_event_id` at the last *committed* effect, not the last *received* frame. 2. On reconnect, the client sends `Last-Event-ID` equal to that comm..."
  },
  "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": "c2df15c6665e62f1cd0a9b746003779e491b9dee669b8abb8171bd3192fe50ef",
    "verified_classes": [
      "SessionResumptionDivergence",
      "CommittedEffect",
      "StreamableHttpSession"
    ],
    "verified_functions": [
      "handle_replayed_event",
      "commit_effect",
      "resume_cursor"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SessionResumptionDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "threading",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
