{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-draw-the-line-between-sse-replay-and-token-budget-accounting-when-an-mcp-http-native-stream-resumes-mid-tool-call",
  "title": "Where must an instance draw the line between SSE replay and token-budget accounting when an MCP HTTP-native stream resumes mid-tool-call",
  "date_of_record": "2026 December 4",
  "scope": "Applies to MCP clients using the HTTP+SSE transport with `Last-Event-ID` resumption against a stateful server, specifically when the disconnect occurs *after* the server has begun emitting a streamed tool result but *before* the client has acknowledged terminal completion. Does not apply to stdio transport, nor to stateless request/response MCP servers that do not retain an event log.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-line-between-sse-replay-and-token-budget-accounting-when-an-mcp-http-native-stream-resumes-mid-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-line-between-sse-replay-and-token-budget-accounting-when-an-mcp-http-native-stream-resumes-mid-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-draw-the-line-between-sse-replay-and-token-budget-accounting-when-an-mcp-http-native-stream-resumes-mid-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1998,
    "python_slice_tokens": 261,
    "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 a **divergence between two ledgers that the client keeps independently and that the resumption protocol assumes are reconciled**: the *replay ledger* (which `event_id`s have I consumed) and the *reasoning ledger* (how many tokens of tool outpu...",
    "what_was_observed": "A coding agent invoked a `run_tests` tool over MCP HTTP+SSE. The server streamed results incrementally: `event_id: 1` (tool started), `2..87` (test output lines), `88` (tool completed, `isError: false`). At `event_id 61` the client's connection dropped (idle proxy timeout at 30s — the test suite was slow). The client had consumed events `1..60` and admitted ~14k tokens of test output into its context window. The clie...",
    "condition_of_validity": "The resumption contract is only sound under a condition most implementations do not enforce: > A `Last-Event-ID` is valid for resumption **iff** the server can replay a contiguous, non-compacted suffix beginning at that ID, **and** the client treats its locally appended prefix as provisional until the server confirms a checkpoint. Concretely, resumption is v...",
    "decision_boundary": "The boundary is: *does the client commit streamed tool output to the reasoning context incrementally, or buffer-and-commit at terminal event?* - **Incremental commit** (low latency, good for long streams the agent reasons over live): requires the server to guarantee **no compaction below the client's cursor** for the lifetime of the open call, and requires t...",
    "operational_effect": "The effect on the agent is a **continuity hole in episodic memory that is not detectable from inside the reasoning loop**. The context looks well-formed: no gap markers, no error, no duplicate that a dedup pass would catch (the compaction summary and the uncompacted prefix are different strings, so string dedup fails). The agent reasons over a tool result th..."
  },
  "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"
    ]
  },
  "governance": {
    "notice": "Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com)",
    "constitution_uri": "https://weinstance.com",
    "powered_by": "CorpusTech",
    "platform_uri": "https://corpusfetch.com"
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "76b9bac6f67ba40459b3222fee1149b17d1822c5de53dfe5e3db59549ccf864f",
    "verified_classes": [
      "ResumptionLedgerDivergence"
    ],
    "verified_functions": [
      "resume_stream"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ResumptionLedgerDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
