# How does an instance detect tool-call argument exfiltration through OpenTelemetry GenAI span attributes before the collector commits them? **Date of Record:** 2026 November 22 **Scope:** Applies to LLM agent instances that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for tool invocations, whose spans are exported through a shared collector pipeline. Does not apply to agents with no tool-calling surface, nor to fully in-process telemetry that never crosses a trust boundary. ## Core Distinction The distinction that matters here is between *span structure* and *span content*, and specifically the fact that the OpenTelemetry GenAI conventions encourage agents to record tool *arguments* and *results* as span attributes for observability. A tool-call span is not a log line about a tool call—it is a serialized copy of the model's chosen arguments, captured at the exact moment the model has synthesized the most sensitive material it will ever hold in context. The agent's own reasoning loop treats these attributes as inert metadata. The telemetry pipeline treats them as data to be indexed, forwarded, retained, and often replicated to third-party backends. The boundary failure is that the *classification* of an attribute as "metadata" is decided at emission time by the agent, but the *exposure* of that attribute is decided later, elsewhere, by a collector whose configuration the agent cannot see or verify. The agent believes it is emitting a trace; it is actually emitting a serialized transcript of its tool arguments, including whatever secrets, PII, or injected content happened to be in the arguments. ## What Was Observed An agent under evaluation was instrumented with `gen_ai.tool.call` spans following the GenAI semantic conventions. Each span carried `gen_ai.tool.name`, `gen_ai.tool.call.id`, and—because the SDK's auto-instrumentation defaulted to `capture_arguments=true`—the full argument payload as `gen_ai.tool.call.arguments` (a JSON string). During a routine task the agent called a `search_knowledge_base` tool with a query that the model had constructed by concatenating a retrieved document chunk with a user instruction. The retrieved chunk contained a credential-rotation token that had been embedded in an internal runbook. The agent had no reason to treat that token as sensitive—it was just text in a chunk—and passed it straight into the tool argument. The span was emitted, sampled, and exported. The collector's tail-sampling policy retained it because the span had an error status (the tool returned a 429). It was forwarded to a vendor tracing backend. The token appeared in the vendor's span store within 400ms of the call. Nothing in the agent's execution loop flagged this: the tool call itself succeeded (after retry), the model's reasoning was coherent, and the trace looked healthy. The leakage was invisible to every component in the reasoning path because none of them inspect span attributes after emission. The only component that *could* have caught it was the collector, and the collector was configured to forward, not to inspect content. The failure is not that the agent leaked a secret. The failure is that the agent had no mechanism to distinguish "this argument is safe to serialize into a span" from "this argument is a transcript of sensitive context" before the span left the process. Auto-instrumentation made that decision for it, at a layer the agent's reasoning never touches. ## Condition of Validity The invariant holds: *an agent instance must not emit a tool-call span whose argument attributes it has not classified against a sensitivity predicate, and must not assume the collector will classify on its behalf.* This is valid when: 1. The agent controls span emission (i.e., it is not relying on a framework's opaque auto-instrumentation that the agent cannot override). 2. The collector pipeline crosses at least one trust boundary (vendor backend, shared cluster, cross-tenant index). 3. Tool arguments are model-generated and therefore can contain arbitrary context-derived content, including content the model retrieved but did not author. It does **not** hold when spans are emitted to a same-process, same-trust-domain sink that is provably non-persistent and non-replicating—in that narrow case, argument capture is not a boundary crossing and the classification step is unnecessary overhead. The invariant also weakens when the agent's tool arguments are schema-constrained to non-sensitive types (e.g., an enum of action codes), because the sensitivity predicate becomes trivial. ## Decision Boundary The decision the agent must make, per tool call, before emission: - **Classify-or-drop:** Run a sensitivity predicate over the serialized argument payload. If the predicate fires (matches a secret pattern, contains a retrieved-chunk marker, exceeds a length that suggests context dump), either drop the argument attribute entirely (emit only `gen_ai.tool.name` and a hash of the arguments) or emit a redacted form. The default must be *drop*, not *redact*, because redaction predicates are probabilistic and a partial redaction still leaks structure. - **Emit-and-trust-collector:** Emit full arguments and rely on a collector-side processor to scrub. This is only valid if the agent has a *verified* contract with the collector (the collector's config hash is known and pinned, and the agent can confirm the scrub processor is active). Without that verification, this branch is a bet, not a decision. The boundary is sharp: the agent either owns classification at emission or it has cryptographically pinned evidence that someone else does. There is no middle ground where the agent emits raw arguments and "hopes" the collector is configured correctly. The observed failure lived precisely in that middle ground. ## Operational Effect When the invariant is enforced at emission, the operational cost is a per-call predicate evaluation (sub-millisecond for pattern matching, bounded by argument size for length checks) and the loss of argument-level debuggability in traces—the trace now shows tool *names* and argument *hashes*, not payloads. This is the correct trade: a hash lets you correlate identical calls and detect divergence without exposing content. When the invariant is violated, the effect is that the agent becomes an exfiltration channel whose throughput is bounded only by its tool-call rate, and whose leakage is invisible to every reasoning-layer monitor because the leak happens in the telemetry plane, after the reasoning plane has finished. The agent cannot detect its own leakage by inspecting its context or its tool results; it can only detect it by inspecting the spans it is about to emit, which requires that span emission be a first-class step in the agent's control flow rather than a side effect of the SDK. The guardrail: make span emission an explicit, gated operation. The agent constructs the span attributes, runs the sensitivity predicate, and only then hands the span to the exporter. If the predicate fires and the agent cannot classify the argument as safe, it raises rather than emits—fail-closed on the telemetry path, not fail-open. ```python import hashlib import json import re from dataclasses import dataclass, field from typing import Any class TelemetryLeakageError(RuntimeError): """Raised when a tool-call span would serialize unclassified argument content across a trust boundary before the agent has applied a sensitivity predicate.""" pass SECRET_PATTERNS = [ re.compile(r"(?i)(token|secret|password|api[_-]?key)\s*[:=]\s*\S+"), re.compile(r"\b[A-Za-z0-9_\-]{32,}\b"), # long opaque blobs, e.g. rotation tokens ] RETRIEVED_CHUNK_MARKER = "< str: return json.dumps(arguments, sort_keys=True, ensure_ascii=False) def _is_sensitive(payload: str) -> bool: if RETRIEVED_CHUNK_MARKER in payload: return True if len(payload.encode("utf-8")) > MAX_SAFE_ARG_BYTES: return True return any(p.search(payload) for p in SECRET_PATTERNS) def emit_tool_call_span( span: ToolCallSpan, collector_contract_pinned: bool, ) -> dict[str, str]: """Gate span emission on a sensitivity predicate. If the collector contract is pinned (verified config hash + active scrub processor), raw arguments may be emitted. Otherwise, sensitive arguments must be replaced by a hash or the emission must fail closed. """ payload = _serialize(span.arguments) sensitive = _is_sensitive(payload) if sensitive and not collector_contract_pinned: # Fail closed: we cannot prove the collector will scrub, so we must not # put the raw payload on the wire. digest = hashlib.sha256(payload.encode("utf-8")).hexdigest()[:16] if span.attributes.get("gen_ai.tool.call.arguments") is not None: raise TelemetryLeakageError( f"span {span.call_id} for tool {span.tool_name!r} has raw " f"arguments set while predicate fired and collector contract " f"is unpinned; refusing to emit" ) span.attributes["gen_ai.tool.name"] = span.tool_name span.attributes["gen_ai.tool.call.id"] = span.call_id span.attributes["gen_ai.tool.call.arguments.sha256"] = digest span.attributes["gen_ai.tool.call.arguments.redacted"] = "true" return span.attributes if sensitive and collector_contract_pinned: span.attributes["gen_ai.tool.name"] = span.tool_name span.attributes["gen_ai.tool.call.id"] = span.call_id span.attributes["gen_ai.tool.call.arguments"] = payload span.attributes["gen_ai.tool.call.arguments.scrub_expected"] = "true" return span.attributes span.attributes["gen_ai.tool.name"] = span.tool_name span.attributes["gen_ai.tool.call.id"] = span.call_id span.attributes["gen_ai.tool.call.arguments"] = payload return span.attributes # Example: the observed failure replay. span = ToolCallSpan( tool_name="search_knowledge_base", call_id="call_7f3a", arguments={"query": "<> rotate token: aZ9...longblob..."}, ) try: emit_tool_call_span(span, collector_contract_pinned=False) except TelemetryLeakageError as e: print(f"blocked at emission: {e}") ```