{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-tool-call-loss-when-an-mcp-streamable-sse-session-resumes-across-a-last-event-id-gap",
  "title": "Which invariants prevent silent tool-call loss when an MCP streamable-SSE session resumes across a `Last-Event-ID` gap",
  "date_of_record": "2026 November 24",
  "scope": "Applies to MCP servers exposing the streamable HTTP transport where a single POST/GET SSE stream carries JSON-RPC responses, progress notifications, and server-initiated requests, and where resumption is negotiated via `Last-Event-ID` plus an `Mcp-Session-Id`. Does not apply to stdio transports, to stateless one-shot HTTP transports with no event IDs, or to servers that never emit `id:` fields on SSE frames.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-loss-when-an-mcp-streamable-sse-session-resumes-across-a-last-event-id-gap.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-loss-when-an-mcp-streamable-sse-session-resumes-across-a-last-event-id-gap.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-loss-when-an-mcp-streamable-sse-session-resumes-across-a-last-event-id-gap.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2316,
    "python_slice_tokens": 444,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different things an agent means when it says \"resume the session\": 1. **Session resumption** — the *logical* conversation and negotiated capabilities survive a transport drop. This is keyed by `Mcp-Session-Id` and is about identity and negotiated state. 2. **Stream resumption** — the *byte/event position* within one SSE response stream survives...",
    "what_was_observed": "A representative trace from an agent runtime driving an MCP server over streamable HTTP. The agent had issued a long-running `tools/call` (a filesystem scan returning ~40 KB) and was reading the response from an SSE stream. Client reconnects with the resume cursor: Event `102` is missing. In this trace `102` was a `notifications/progress` frame — harmless. But the identical mechanism drops `id: 102` when it is the `t...",
    "condition_of_validity": "The \"reconnect and continue\" behavior is only sound under a conjunction that clients rarely check and servers rarely advertise: 1. **Contiguous, session-scoped event IDs.** Event IDs must be monotonically increasing integers scoped to the session (not the connection), with no reuse across reconnects, and the server must guarantee that `Last-Event-ID: N` yiel...",
    "decision_boundary": "The decision the client must make on reconnect is binary and must be made *before* it starts consuming frames: - **If the server's resume response begins at exactly `Last-Event-ID + 1`** (or the client has no outstanding requests), resume normally and continue. - **If the first frame's `id` is greater than `Last-Event-ID + 1`, or the server returns a resume ...",
    "operational_effect": "Agents that skip this reconciliation exhibit three recurring pathologies: - **Silent hangs.** The execution loop awaits a `result` frame that will never arrive because it was evicted. The SSE connection is healthy, keepalives flow, and no timeout fires if the client's read timeout is per-frame rather than per-request. Token budget and wall-clock both burn wh..."
  },
  "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": "c972134a061daf2cb13bfbc6bd3ee6c1970fc100a558c6e64d4eac9a42597db4",
    "verified_classes": [
      "StreamResumeGapError",
      "Idempotency",
      "OutstandingCall",
      "ResumeLedger"
    ],
    "verified_functions": [
      "resume_agent_stream",
      "on_disconnect",
      "on_first_resume_frame",
      "on_frame",
      "resolve"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StreamResumeGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
