{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-state-exactly-once-after-an-sse-to-streamable-http-migration",
  "title": "Why does an instance lose tool-call state exactly once after an SSE-to-streamable-HTTP migration?",
  "date_of_record": "2026 November 12",
  "scope": "Applies to MCP servers that expose the same logical endpoint under both the legacy HTTP+SSE transport and the streamable-HTTP transport during a migration window, where clients may resume sessions via `Last-Event-ID` or `Mcp-Session-Id`. Does not apply to pure stdio transports or to deployments that hard-cut over to streamable-HTTP with no dual-listener window.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-state-exactly-once-after-an-sse-to-streamable-http-migration.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-state-exactly-once-after-an-sse-to-streamable-http-migration.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-state-exactly-once-after-an-sse-to-streamable-http-migration.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1559,
    "python_slice_tokens": 229,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is that **session identity and event-stream identity are two different things**, and the migration window conflates them. In the legacy SSE transport, a session is implicitly the lifetime of one long-lived `GET` stream; the `Last-Event-ID` header is the only resumption primitive, and it is scoped to that single stream. In streamable-...",
    "what_was_observed": "During a staged migration, a server ran both listeners behind one router. A client opened a legacy SSE stream, received events `e-100` through `e-104` (the last being a `tools/call` result for `search_index`), and then the SSE connection was severed by an idle proxy timeout before the client's read loop drained `e-104`. The client reconnected using the streamable-HTTP endpoint, sending `Mcp-Session-Id: s-77` and `Las...",
    "condition_of_validity": "This failure requires all of the following to hold simultaneously: - A dual-listener window where legacy SSE and streamable-HTTP share an event-ID allocator (monotonic or otherwise) rather than namespacing by transport. - Session bridging that accepts a legacy session ID at the streamable-HTTP endpoint. - A resume cursor whose value equals the ID of an event...",
    "decision_boundary": "The operational choice is between two resumption contracts, and the migration must pick one explicitly rather than inheriting whichever the legacy code happened to implement: - **At-most-once replay (`> cursor`):** safe against duplicate delivery, unsafe against the drain-race above. Correct only when the client can independently detect a missing response (e...",
    "operational_effect": "The practical consequence is that migration correctness cannot be validated by \"the client reconnected and the stream is live.\" Liveness is preserved in both contracts; only delivery completeness differs, and it differs by exactly one event. Teams that tested the migration with short-lived streams and clean disconnects saw no failures, because a clean discon..."
  },
  "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": "106087499d055b25a96a7a613756c0b383e6650b210f12da74e1566e3c95c630",
    "verified_classes": [
      "ResumeCursorRaceError"
    ],
    "verified_functions": [
      "resume_stream"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ResumeCursorRaceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
