{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-mcp-streamable-http-session-resumption-from-replaying-a-partial-tool-call-frame-into-a-fresh-sse-stream",
  "title": "Which invariants prevent MCP streamable-HTTP session resumption from replaying a partial tool-call frame into a fresh SSE stream",
  "date_of_record": "2026 November 23",
  "scope": "Applies to MCP servers and clients using the streamable-HTTP transport (single POST endpoint, optional SSE upgrade, `Mcp-Session-Id` header, `Last-Event-ID` resumption). Does not cover stdio transport, nor WebSocket-based custom transports, nor resumption of *server-to-client* notifications that were never assigned an event ID.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-http-session-resumption-from-replaying-a-partial-tool-call-frame-into-a-fresh-sse-stream.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-http-session-resumption-from-replaying-a-partial-tool-call-frame-into-a-fresh-sse-stream.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-http-session-resumption-from-replaying-a-partial-tool-call-frame-into-a-fresh-sse-stream.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2073,
    "python_slice_tokens": 305,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure that matters is not \"the SSE connection dropped.\" That is normal and recoverable. The failure is **resuming a stream at the wrong byte boundary of a JSON-RPC message and treating the replayed fragment as a complete frame**. MCP streamable-HTTP allows a client to reconnect to a session and pass `Last-Event-ID` to ask the server to replay events af...",
    "what_was_observed": "A tool-calling agent issued `tools/call` for a long-running retrieval tool. The server streamed the result as three SSE events because the payload exceeded its internal 8 KB flush threshold: - `id: 41` — `data: {\"jsonrpc\":\"2.0\",\"id\":\"c7\",\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"...first 6KB...` - `id: 42` — `data: ...continued 6KB...` - `id: 43` — `data: ...final 2KB...\"}]}}` Mid-stream the client's TCP connection...",
    "condition_of_validity": "The bug is bounded by three conditions, all of which must hold for the corruption to occur: 1. **Message fragmentation across events.** The server's flush policy splits a single JSON-RPC message across ≥2 SSE events. This happens whenever the message exceeds the server's write buffer, or when the server interleaves `notifications/progress` between chunks of ...",
    "decision_boundary": "The boundary is: **may the client advance `Last-Event-ID` past an event that belongs to an incomplete JSON-RPC message?** - **No** (correct): the client tracks two cursors — `last_complete_message_event_id` and `last_received_event_id`. On reconnect it resumes from `last_complete_message_event_id` and discards any retained partial buffer for the in-flight me...",
    "operational_effect": "Consequences for an agent runtime: - **Duplicate side effects on non-idempotent tools.** The parse-error → retry path is indistinguishable from a genuine tool failure to the reasoning loop. The agent must not treat a stream-resumption parse error as a tool error; it must treat it as a *transport* error and resume rather than re-invoke. This requires the clie..."
  },
  "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": "0f53aea6d7ace2844ce5ff523e27171bab038d61314948d341ad89bb24f3b114",
    "verified_classes": [
      "ResumptionFragmentError",
      "MessageBoundaryCursor"
    ],
    "verified_functions": [
      "ingest_event",
      "resume_from",
      "assert_resumable"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "ResumptionFragmentError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
