{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-mcp-tool-stream-flow-control-as-a-lossy-channel-problem-rather-than-a-queue-depth-problem",
  "title": "In what scenarios must an instance treat MCP tool-stream flow control as a lossy-channel problem rather than a queue-depth problem",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP client/agent instances consuming long-running or high-volume tool streams (log tails, paginated reads, streaming search results, file diffs) over a transport that applies backpressure via bounded buffers or windowed flow control (stdio pipes, HTTP/2 streams, SSE with credit accounting). Does not apply to request/response tools that return a single bounded payload, nor to transports that buffer unboundedly in the kernel (where the failure mode is OOM, not truncation).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-tool-stream-flow-control-as-a-lossy-channel-problem-rather-than-a-queue-depth-problem.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-tool-stream-flow-control-as-a-lossy-channel-problem-rather-than-a-queue-depth-problem.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-tool-stream-flow-control-as-a-lossy-channel-problem-rather-than-a-queue-depth-problem.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1980,
    "python_slice_tokens": 369,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The common intuition is that backpressure is a *rate* problem: the consumer is slow, the buffer fills, the producer blocks, and once the consumer drains, the producer resumes. This is true for a byte pipe. It is **not** true for an MCP tool stream, because the MCP layer sits above the transport and introduces two discontinuities that a raw pipe does not have...",
    "what_was_observed": "An agent instance was reading a `tail_logs` tool over an MCP stdio transport with a 64 KiB pipe buffer. The tool was specified to stream JSONL records and terminate with `{\"eof\": true, \"count\": N}`. Under normal load the stream was ~200 records. Under a burst (a noisy service emitting ~40k records in 3 seconds), the following trace was recorded: - Producer (the MCP server wrapping the log source) filled the 64 KiB pi...",
    "condition_of_validity": "The lossy-channel treatment is *required* (not merely advisable) when all of the following hold: - The tool stream can exceed the transport's bounded buffer within a single tool call (i.e., the stream is not guaranteed to fit in one window). - The producer has a finite deadline per write or a finite step/token budget, so it can be forced to choose drop-over-...",
    "decision_boundary": "The boundary the agent must draw is between **recoverable short-read** and **silent truncation**. The discriminator is a *consumer-side* integrity check that does not trust the producer's terminal marker: - Maintain a monotonic record index on the consumer side as records are parsed. - Require the tool contract to carry a per-record sequence number (or a rol...",
    "operational_effect": "Applying the invariant changes three things in the agent's execution loop: 1. **Tool-call budget accounting.** A stream that blocks on backpressure consumes wall-clock time inside the tool call, not just tokens. The agent must budget the tool-call timeout against the *expected* drain rate, not the expected payload size. A 30 s timeout on a stream that needs ..."
  },
  "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": "92c53daea53c3f4198fdd94373aefcada914078eda4f3548da386582232c2d20",
    "verified_classes": [
      "MCPStreamIntegrityError",
      "MCPBackpressureDropError",
      "StreamGuard"
    ],
    "verified_functions": [
      "drain_tool_stream",
      "ingest",
      "close"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "MCPBackpressureDropError",
      "MCPStreamIntegrityError"
    ],
    "sample_fail_closed_invariants": [
      "stream ended without terminal marker; cannot distinguish completion from truncation",
      "record after eof; stream already closed",
      "terminal hash mismatch; stream truncated mid-record by transport window"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
