{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-mcp-streamable-transport-session-reattachment-from-silently-forking-an-agent-s-tool-call-history",
  "title": "Which invariants prevent MCP streamable-transport session reattachment from silently forking an agent's tool-call history",
  "date_of_record": "2026 November 24",
  "scope": "Applies to MCP servers and clients using the HTTP-native streamable transport (POST for client→server messages, optional SSE upgrade for server→client streaming) with resumable-event fallback and `Mcp-Session-Id`-based reattachment. Does not cover stdio transport, pure WebSocket transports, or stateless single-request tool servers that never emit a session id.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-transport-session-reattachment-from-silently-forking-an-agent-s-tool-call-history.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-transport-session-reattachment-from-silently-forking-an-agent-s-tool-call-history.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-streamable-transport-session-reattachment-from-silently-forking-an-agent-s-tool-call-history.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2216,
    "python_slice_tokens": 425,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"the connection dropped.\" It is that a resumable stream and a reattached session are two different recovery primitives with two different identity guarantees, and the transport spec allows a client to satisfy one while violating the other. A resumed SSE stream guarantees **byte-continuity of the server→client event log** from a `Last-...",
    "what_was_observed": "An agent driver held an open POST-initiated SSE stream (transport upgraded to `text/event-stream`) while executing a multi-step tool sequence. Step 3 (`write_file`) had been dispatched; the client had emitted the request but not yet received the result event. The underlying TCP connection was severed by an intermediary load balancer after 60s idle (the agent was mid-`reasoning` token stream, so no application bytes f...",
    "condition_of_validity": "The reattachment invariant holds only under the conjunction: 1. **Event-id monotonicity is per-session, not global.** `Last-Event-ID` is meaningful only relative to the session's own event sequence. A server must not reuse a session id across an event-sequence reset (e.g., after a server restart that re-zeroes the counter). If it does, a client's `Last-Event...",
    "decision_boundary": "The boundary is between **resumable** and **reattachable**, and it must be decided per reconnect attempt, not assumed: - If the client's `Last-Event-ID` is present and the server's retained buffer's minimum id is ≤ that id, the reconnect is a **resume**: the client may trust that all events after that id will be delivered in order, and may replay unacknowled...",
    "operational_effect": "For an agent, the operational consequence is that **the local tool-call ledger is not authoritative across a reconnect.** Any ledger entry in `PENDING` at the moment of disconnect must be treated as `UNKNOWN` after reattachment unless the server's resumed stream delivers its terminal event. The agent must insert a reconciliation step — a `read_file`, a `list..."
  },
  "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": "dc4042645278ab6d7566e6961b5002adf232f8df41198fcdb94193ee7e4584f7",
    "verified_classes": [
      "StreamContinuityError",
      "EventBuffer",
      "ClientLedger"
    ],
    "verified_functions": [
      "reattach",
      "commit_tool_result"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "StreamContinuityError"
    ],
    "sample_fail_closed_invariants": [
      "session id reused across event-sequence reset; cannot honor resume point (ABA hazard)",
      "reattach without Last-Event-ID: in-flight history unknown; client must reconcile before trusting PENDING calls"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
