{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-its-mcp-stream-session-when-sse-backpressure-coalesces-the-resumption-cursor-past-unflushed-tool-call-deltas",
  "title": "Why does an instance lose its MCP stream session when SSE backpressure coalesces the resumption cursor past unflushed tool-call deltas",
  "date_of_record": "2026 November 28",
  "scope": "Applies to MCP servers using HTTP-native transport with Server-Sent Events streaming and `Last-Event-ID`-based session resumption, where a single stream carries tool-call deltas, progress notifications, and result frames. Does not apply to WebSocket transports, stdio transports, or stateless request/response MCP deployments with no resumption contract.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-stream-session-when-sse-backpressure-coalesces-the-resumption-cursor-past-unflushed-tool-call-deltas.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-stream-session-when-sse-backpressure-coalesces-the-resumption-cursor-past-unflushed-tool-call-deltas.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-mcp-stream-session-when-sse-backpressure-coalesces-the-resumption-cursor-past-unflushed-tool-call-deltas.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2080,
    "python_slice_tokens": 349,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the connection dropped.\" Drops are expected and recoverable. The failure is that the **resumption cursor advanced while the frame it referenced was still buffered in the server's SSE write queue**, so on reconnect the client re-requested from a cursor position that had already been acknowledged but whose payload had never left the server....",
    "what_was_observed": "A client agent issued a `tools/call` for a long-running operation. The server streamed the call as a sequence of SSE frames: an initial `tool_call_start`, a run of `tool_call_delta` frames carrying partial JSON arguments, periodic `progress` notifications, and a final `tool_call_result`. Each frame carried a monotonically increasing `id:` field. The client's TCP receive window filled (a slow consumer—its own downstre...",
    "condition_of_validity": "This failure requires the conjunction of four conditions; remove any one and the boundary holds: 1. **Cursor assignment decoupled from flush.** The server assigns `id:` at enqueue, and its replay log's retention watermark advances on enqueue acknowledgment rather than on socket-drain acknowledgment. This is the root cause. Many SSE implementations do this be...",
    "decision_boundary": "The operational decision is: **what does the server's replay log retention watermark track—enqueue or flush?** These are the same under no backpressure and diverge exactly when the consumer is slow, which is exactly when resumption matters. The boundary condition is the moment the socket becomes unwritable while the event-ID counter is live. At that instant:...",
    "operational_effect": "Without the guardrail, the failure mode is **silent prefix corruption of tool-call arguments under consumer backpressure**, with the corruption rate rising precisely when the client is busiest (slow consumer = backpressure = divergence window). The client proceeds on truncated arguments that pass schema validation because they are a valid prefix, producing d..."
  },
  "matched_failure_symptoms": [
    "HTTP_429_BURST_STARVATION"
  ],
  "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": "7fb1a78f2e35367cda31af3a4c53cae02a04887f107d4fe47dea01b272685e72",
    "verified_classes": [
      "StreamResumptionGap",
      "FlushConfirmedReplayLog"
    ],
    "verified_functions": [
      "assemble_tool_call_deltas",
      "__init__",
      "enqueue",
      "confirm_flushed",
      "resume_from"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StreamResumptionGap"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
