{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-s-mcp-tool-sandbox-leaks-state-through-a-reused-egress-socket-during-a-mid-task-retry",
  "title": "What happens when an instance's MCP tool sandbox leaks state through a reused egress socket during a mid-task retry",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agent runtimes that execute MCP (Model Context Protocol) tool calls inside a per-call sandbox with an egress proxy, where a failed tool call is retried within the same session. Does not apply to stateless single-shot tool invocations, or to runtimes that tear down the entire session (including the egress proxy connection pool) on any tool error.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-mcp-tool-sandbox-leaks-state-through-a-reused-egress-socket-during-a-mid-task-retry.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-mcp-tool-sandbox-leaks-state-through-a-reused-egress-socket-during-a-mid-task-retry.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-s-mcp-tool-sandbox-leaks-state-through-a-reused-egress-socket-during-a-mid-task-retry.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1985,
    "python_slice_tokens": 376,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *sandbox isolation of the process* and *isolation of the egress channel*. Most runtimes correctly isolate the tool process: each MCP tool call spawns a subprocess or container with a restricted filesystem, a per-call capability manifest, and a network namespace that only permits traffic to the egress proxy. What they d...",
    "what_was_observed": "A tool call to a remote MCP server (`records.lookup`) timed out at the sandbox's 8s wall clock while the upstream server was still processing. The sandbox killed the tool process and returned a `ToolTimeout` to the agent loop. The agent's retry policy — standard exponential backoff, three attempts — reissued the identical `tools/call` 400ms later. The retry succeeded in 120ms. That is the anomaly: the original reques...",
    "condition_of_validity": "The failure requires four conditions to co-occur: 1. **The egress proxy pools upstream connections across tool calls.** If each tool call gets a fresh upstream connection (no pooling), the abandoned response has nowhere to land. 2. **The sandbox aborts the tool process without closing the proxy's upstream socket.** A timeout that kills the client but not the...",
    "decision_boundary": "The architectural invariant required is: **a tool-call retry must not share an egress connection with the attempt it is retrying.** Concretely, the runtime must enforce one of: - **Connection-per-attempt on retry:** the proxy marks a connection \"poisoned\" when the sandbox aborts a call that had an in-flight upstream request, and refuses to reuse it for any s...",
    "operational_effect": "Without this invariant, an agent's retry policy becomes a *replay policy* with unbounded, invisible consequences. The agent's error-handling logic — backoff, attempt counting, latency budgeting — operates on a model of independent attempts that the transport layer silently violates. The observable symptoms are: - Retries that succeed faster than the original..."
  },
  "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": "a86668f5dce70d5b87645e7538023c03006c602961d03450126e14862c6a5446",
    "verified_classes": [
      "EgressReuseViolation",
      "EgressProxy"
    ],
    "verified_functions": [
      "issue_retry",
      "__init__",
      "mark_aborted",
      "confirm_drained",
      "acquire_for_retry"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "EgressReuseViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
