{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-its-last-tool-result-when-an-mcp-sse-stream-resumes-across-a-rebalanced-session",
  "title": "Why does an instance lose its last tool result when an MCP SSE stream resumes across a rebalanced session",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP servers using the HTTP-native transport with `text/event-stream` responses, per-event `id` fields, `Last-Event-ID` resumption, and a load balancer that enforces session affinity via a cookie or header. Does not apply to stdio transports, to stateless request/response MCP servers that never emit resumable SSE, or to streams without event IDs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-last-tool-result-when-an-mcp-sse-stream-resumes-across-a-rebalanced-session.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-last-tool-result-when-an-mcp-sse-stream-resumes-across-a-rebalanced-session.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-last-tool-result-when-an-mcp-sse-stream-resumes-across-a-rebalanced-session.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2266,
    "python_slice_tokens": 319,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the stream dropped.\" Streams drop constantly and resumption is designed for that. The failure is that **resumption is only correct if the event ID is a position in a replayable log owned by the process that will serve the resume** — and session affinity is a *routing* promise that does not, by itself, guarantee that the replaying process ...",
    "what_was_observed": "An agent issued a `tools/call` for a long-running operation (a code interpreter run, ~40s). The server acknowledged the call on the SSE stream with a `tool_use`-style progress event carrying `id: 41`. The HTTP connection was then severed by an idle timeout on an intermediate proxy at 30s. The agent's MCP client reconnected with `Last-Event-ID: 41`. Meanwhile the pod backing the session had been evicted (node pressure...",
    "condition_of_validity": "The resumption invariant holds **only if** the following three conditions are simultaneously true: 1. **Replay ownership.** The event IDs emitted on a stream are backed by a log that the *resuming* process can read. If the log is in-process memory, then affinity failover breaks replay. If the log is in the shared store, replay is possible but you pay a write...",
    "decision_boundary": "The correct decision boundary is a single comparison, performed in the resume handler *before* any event is emitted: - If `gap == false`: resume normally from `requested + 1`. - If `gap == true` **and** the shared store can supply the missing range: replay from the store, then continue live. - If `gap == true` **and** the store cannot supply the range: **fai...",
    "operational_effect": "Downstream, this manifests as three distinct agent-level pathologies that are easy to misattribute: 1. **Silent result loss → duplicate side effects.** The agent, seeing no `tool_result`, retries the `tools/call`. For idempotent reads this is benign; for writes, sends, or payments it duplicates. The duplication is invisible in the transport layer because eac..."
  },
  "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": "a325ad228d425f88ac1e1dd2603419ece9e5b36bed0201ffb4b755c74c15f0f2",
    "verified_classes": [
      "UnreplayableResumeGap",
      "EventLog"
    ],
    "verified_functions": [
      "resume_stream",
      "handle_resume",
      "can_replay"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnreplayableResumeGap"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
