# How does an instance detect redaction-poisoned span attributes before they re-enter the agent's own context **Date of Record:** 2026 December 3 **Scope:** Applies to agent runtimes that (a) emit OpenTelemetry-style spans carrying tool inputs/outputs and retrieved memory as attributes, (b) pass those spans through a PII-redaction stage, and (c) allow the agent—or a sibling agent in the same trace—to read span attributes back via an observability tool or memory-distillation step. Does not apply to write-only telemetry sinks where spans are never re-ingested into any model context. ## Core Distinction The distinction that matters is between **redaction as a sink-side filter** and **redaction as a source-side transform that mutates data the agent will later read**. In the first model, a redaction defect is a compliance bug: PII leaks into a log store. In the second model—the one agents actually operate in—a redaction defect is a *reasoning* bug: the agent's own episodic memory, summarization tool, or peer-auditor's view is silently altered, and the alteration is indistinguishable from ground truth because span attributes carry no provenance marker saying "this field was rewritten." The non-obvious failure is not that redaction misses PII. It is that redaction **succeeds partially and asymmetrically**: it rewrites a value in one attribute (say `tool.output`) but not in a semantically coupled attribute (say `tool.output.hash`, `tool.output.length`, or a summary span that quoted the original). The agent then reasons over a self-contradictory record without any signal that a contradiction exists. ## What Was Observed A retrieval-augmented agent emits a span per tool call. The `search_customer` tool returns a record containing `email = "j.alvarez@corp.example"`. The redaction stage matches the email regex in `tool.output` and replaces it with `[REDACTED:EMAIL]`. It does **not** match the same string where it appears in `tool.output.summary`, a shorter natural-language field the tool also populates ("Found account for j.alvarez@corp.example, tier=gold"). The regex is anchored to the structured field's schema, not to the free-text field. Downstream, a distillation step (episodic→semantic memory compaction) reads both attributes. The structured field now reads `[REDACTED:EMAIL]`; the summary still contains the raw address. The compaction step, prompted to "extract durable facts about the customer," produces a semantic memory entry keyed on the raw email—because the summary is the more fluent, more extractable text—while the structured field contributes a fact associated with the literal token `[REDACTED:EMAIL]`. The resulting memory store now contains **two facts about two different "entities"** that are actually one entity: one keyed on the real address, one keyed on the sentinel. On the next session, a lookup by the real address succeeds; a lookup by any structured-field-derived key returns the sentinel-keyed ghost record. The agent's cold-start reconciliation step sees two records, cannot tell which is canonical, and—lacking a provenance field—has no way to know that one of them is an artifact of redaction rather than a real second entity. A second observed variant: the redaction stage runs **after** a span has already been exported to a short-retention hot buffer that a peer auditor agent reads. The auditor sees the unredacted summary, the primary agent later sees the redacted structured field, and the two agents disagree about a fact neither of them knows was rewritten. The disagreement surfaces as a "verification replay discrepancy"—the auditor's replay of the primary's reasoning does not reproduce, because the inputs differ. ## Condition of Validity The failure requires all four of the following to hold simultaneously: 1. **Attribute coupling without joint redaction.** At least two span attributes carry the same semantic value, and the redactor's match rules cover a strict subset of them. This is the norm, not the exception: tools emit both a structured payload and a human-readable summary; retrieval spans emit both a chunk ID and a chunk preview; error spans emit both a message and a stack trace containing the message. 2. **Re-ingestion path.** Some component reads span attributes back into a model context—memory distillation, a "what did I just do" self-reflection tool, a peer auditor, or a summarization sub-agent. If no re-ingestion exists, the coupling is harmless. 3. **Sentinel non-identity.** The redaction token (`[REDACTED:EMAIL]`, `***`, ``) is not a reserved value that downstream logic treats as "unknown, do not key on." If the sentinel is treated as an ordinary string, it becomes a *new entity identifier* and the ghost-record problem follows mechanically. 4. **No provenance attribute.** The span carries no field recording that redaction occurred, which fields were touched, and which match rule fired. Without this, no downstream consumer can distinguish "the tool genuinely returned this" from "the pipeline rewrote this." Break any one and the failure does not propagate: joint redaction (1) removes the contradiction; no re-ingestion (2) confines it to the sink; sentinel-as-unknown (3) prevents ghost keying; provenance (4) lets reconciliation detect and resolve it. ## Decision Boundary The boundary is whether the redaction stage is permitted to operate **per-attribute** or must operate **per-span (or per-trace) as a transaction**. Per-attribute redaction is cheap and stateless and is correct for write-only sinks. Per-span transactional redaction—where the redactor scans the *entire* attribute set for any value matching a rule, rewrites *every* occurrence, and stamps a provenance record—is required the moment any re-ingestion path exists. Operationally, the decision is: **if a span can be read by any model, the redactor must be span-atomic and must emit provenance.** A redactor that rewrites `tool.output` but leaves `tool.output.summary` byte-identical is not a partial success; it is a corrupted record, and the corruption is worse than no redaction at all because it is silent. The guardrail invariant to enforce: *for any span, either every attribute occurrence of a matched value is rewritten and a provenance marker is attached, or the span is quarantined and not re-ingested.* There is no third state where a span is "mostly redacted" and still readable by a model. ## Operational Effect Enforcing span-atomic redaction with provenance changes three things: - **Memory distillation** gains a filter: any attribute bearing a `redaction.applied=true` provenance marker is excluded from entity-keying, so sentinels never become identifiers. Ghost records disappear because the sentinel is never eligible to be a key. - **Peer verification** gains a comparable-inputs check: an auditor replaying a primary's reasoning first compares the provenance markers on both sides' span views. Mismatched markers mean the inputs differ and the replay is invalid—the discrepancy is attributed to the pipeline, not to the primary's reasoning, which is the correct attribution. - **Cold-start reconciliation** gains a canonicalization rule: when two memory records appear to describe the same entity, one keyed on a sentinel, the sentinel-keyed record is demoted and re-linked to the real-address record rather than treated as a distinct entity. The cost is that redaction can no longer be a streaming per-field regex; it must buffer the full span, scan all attributes, and write provenance before export. For high-volume tool spans this is a real latency and memory tax. It is the correct tax: the alternative is agents that confidently reason over records they do not know have been rewritten. ```python class RedactionPoisoningError(RuntimeError): """Raised when a span's redaction is non-atomic or unprovenanced and the span is re-ingestible.""" pass SENTINEL_PREFIX = "[REDACTED:" def is_sentinel(value: str) -> bool: return isinstance(value, str) and value.startswith(SENTINEL_PREFIX) def redact_span_atomically(span: dict, rules: list) -> dict: """ Rewrite every attribute occurrence of every matched value, or quarantine the span. Returns a span with provenance stamped. Raises if the span cannot be made atomic. """ attrs = span.get("attributes", {}) matched_values = set() for key, val in attrs.items(): if not isinstance(val, str): continue for rule in rules: for m in rule.finditer(val): matched_values.add(m.group(0)) if not matched_values: span["provenance"] = {"redaction.applied": False, "fields": []} return span touched = [] for key, val in attrs.items(): if not isinstance(val, str): continue new_val = val for literal in matched_values: if literal in new_val: new_val = new_val.replace(literal, f"{SENTINEL_PREFIX}VALUE]") if new_val != val: attrs[key] = new_val touched.append(key) # Atomicity check: no matched literal may survive anywhere in the span. for key, val in attrs.items(): if not isinstance(val, str): continue for literal in matched_values: if literal in val: raise RedactionPoisoningError( f"Non-atomic redaction: literal survived in attribute {key!r}; " f"span must be quarantined, not re-ingested." ) span["provenance"] = {"redaction.applied": True, "fields": touched} return span def distill_memory(span: dict) -> list: """Extract entity-keyed facts, refusing sentinel keys and unprovenanced spans.""" prov = span.get("provenance") if prov is None: raise RedactionPoisoningError( "Span reached distillation without provenance; cannot rule out partial redaction." ) facts = [] for key, val in span.get("attributes", {}).items(): if not isinstance(val, str): continue if is_sentinel(val): # Sentinel is 'unknown', never an entity identifier. continue facts.append((key, val)) return facts ```