{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-resumes-an-mcp-streamable-session-across-a-backpressure-gap-and-the-server-has-silently-compacted-its-replay-buffer",
  "title": "What happens when an instance resumes an MCP streamable-session across a backpressure gap and the server has silently compacted its replay buffer",
  "date_of_record": "2026 November 27",
  "scope": "Applies to MCP servers using the streamable HTTP transport (SSE-over-POST with `Mcp-Session-Id` and `Last-Event-ID` resumption) when a client reconnects after a transport-level interruption. Does not apply to stdio transport, nor to stateless HTTP servers that do not issue session IDs or event IDs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-streamable-session-across-a-backpressure-gap-and-the-server-has-silently-compacted-its-replay-buffer.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-streamable-session-across-a-backpressure-gap-and-the-server-has-silently-compacted-its-replay-buffer.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-resumes-an-mcp-streamable-session-across-a-backpressure-gap-and-the-server-has-silently-compacted-its-replay-buffer.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2423,
    "python_slice_tokens": 406,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two semantically distinct resumption failure classes, and conflating them is the root of the bug. The first is *lost events*: the client resumes with `Last-Event-ID: N`, the server has retained events `> N`, and it replays them — the client's logical task state is reconstructed exactly. The second is *compacted events*: the server's replay ring buf...",
    "what_was_observed": "Trace from a session where a client agent issued a long-running `tools/call` (a code-index rebuild, ~90 s) over streamable HTTP. The client read the SSE stream through a proxy that applied backpressure: when the client's downstream consumer (a token-budget governor) paused reads to drain its own queue, the proxy stopped reading from the upstream socket, the server's send buffer filled, and the server's per-session ev...",
    "condition_of_validity": "The invariant holds — and the guardrail is required — exactly when all of the following are true: 1. The transport issues per-session monotonic `id:` fields on SSE events and honors `Last-Event-ID` on reconnect (i.e., it is genuinely resumable, not just streamable). 2. The server's replay retention is bounded (ring buffer, TTL eviction, or per-session event ...",
    "decision_boundary": "The server's resumption handler must branch on a single comparison, and the branch must be explicit: - **`last_event_id >= watermark`** (requested ID is still retained): replay from `last_event_id + 1`. This is a *complete resume*. Stream normally. - **`last_event_id < watermark`** (requested ID has been evicted): this is a *compacted resume*. The server MUS...",
    "operational_effect": "With the guardrail, the double-rebuild in the trace becomes a single, clean failure: the client reconnects at `#128`, the server responds `409` with `{\"requested\": 128, \"watermark\": 356}`, the client's session supervisor marks the session `desynced`, discards its in-flight table, and re-drives the task from its last durable checkpoint (the checkpoint it took..."
  },
  "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": "fecad9a7535a3b67326faa17176505bd680670105e3367bccbe1658f7ed3015a",
    "verified_classes": [
      "CompactionGapError",
      "ReplayBuffer"
    ],
    "verified_functions": [
      "handle_resume",
      "__init__",
      "replay_from"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
