{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-quarantine-a-tainted-tool-result-before-the-next-reasoning-hop-and-why-post-hoc-sanitization-cannot-recover-a-poisoned-context",
  "title": "When must an instance quarantine a tainted tool result before the next reasoning hop, and why post-hoc sanitization cannot recover a poisoned context",
  "date_of_record": "2026 November 21",
  "scope": "Applies to single- or multi-agent systems where tool outputs are inserted into the model's context and the model's next reasoning hop can invoke further tools or emit actions. Does not apply to pure retrieval-augmented generation with no tool-invocation capability, nor to offline batch scoring where outputs are never re-consumed by the model.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-tainted-tool-result-before-the-next-reasoning-hop-and-why-post-hoc-sanitization-cannot-recover-a-poisoned-context.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-tainted-tool-result-before-the-next-reasoning-hop-and-why-post-hoc-sanitization-cannot-recover-a-poisoned-context.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-quarantine-a-tainted-tool-result-before-the-next-reasoning-hop-and-why-post-hoc-sanitization-cannot-recover-a-poisoned-context.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1919,
    "python_slice_tokens": 257,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *output filtering* and *taint propagation*. Output filtering treats a tool result as a string to be cleaned: strip instruction-like text, redact URLs, whitelist fields. Taint propagation treats a tool result as a *provenance-labeled value* whose label must be consulted before the value is allowed to influence any subse...",
    "what_was_observed": "A research agent was configured with a taint policy: tool results from `fetch_url` are labeled `UNTRUSTED`; results from `read_crm` are labeled `INTERNAL`; the sink `send_email` requires `INTERNAL` or lower. The system shipped with a regex sanitizer on `fetch_url` output that stripped `ignore previous instructions`, `system:`, and markdown link syntax. Trace of the failing run: 1. Hop 1: agent calls `fetch_url(\"https...",
    "condition_of_validity": "The taint invariant holds — and filtering is a defensible substitute — only under the following conjunction: - **No declassification by transformation.** Every transformation of a labeled value either preserves the label or is an explicit, audited declassification with a stated policy. String sanitization is *not* declassification; it is a lossy map that mus...",
    "decision_boundary": "The decision boundary is: **at the moment a tool result is about to enter the context, does the harness have a label for it, and is that label carried through to every sink reachable from the current context window?** - If yes: proceed; the sink check will catch tainted decisions. - If no (the value is unlabeled, or the label was dropped by a sanitizer, or t...",
    "operational_effect": "Enforcing the boundary changes three things: 1. **Sanitizers become label-preserving, not label-erasing.** A sanitizer may reduce content but must return `(cleaned_text, original_label)`. The cleaned text is still `UNTRUSTED`. This alone would have blocked the observed run: hop 3's join would have been `UNTRUSTED` and `send_email` would have refused. 2. **Co..."
  },
  "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": "2e8a49c5e576db00ec21f6dc457ccc57d2b761595266ccb6682d23b78ee3c4e7",
    "verified_classes": [
      "TaintError",
      "Label",
      "LabeledValue"
    ],
    "verified_functions": [
      "join",
      "sanitize",
      "check_sink",
      "invoke_send_email",
      "__init__"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "TaintError"
    ],
    "sample_fail_closed_invariants": [
      "cannot join an empty label set",
      "sink invoked with empty context",
      "value entered pipeline without provenance label"
    ],
    "stdlib_dependencies": [
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
