# In what scenarios must an instance treat OpenTelemetry GenAI span attributes as non-authoritative for tool-call reconstruction **Date of Record:** 2026 November 28 **Scope:** Applies to agent runtimes that emit `gen_ai.*` spans (per the OpenTelemetry GenAI semantic conventions) and later replay those spans to reconstruct tool-call history, budget accounting, or handoff state. Does not apply to spans used purely for latency dashboards or cost aggregation where per-call argument fidelity is irrelevant. ## Core Distinction The GenAI semantic conventions describe *observability* attributes, not a *serialization contract*. A span is a lossy, best-effort, sampled, and redaction-filtered record of what an agent did. The distinction that matters operationally is between **the execution trace** (the authoritative, causally ordered record the runtime itself holds) and **the telemetry projection** (the `gen_ai.*` attributes emitted to a collector). These diverge in ways that are silent: attribute truncation, sampling, PII scrubbing, and the fact that `gen_ai.tool.call.arguments` / `gen_ai.tool.call.result` are conventionally string-encoded and size-capped. An instance that treats the projection as the trace will reconstruct a *plausible but wrong* tool-call history—wrong enough to mis-account token budgets, replay a destructive tool call, or feed a corrupted episodic memory into the next turn. ## What Was Observed A multi-step agent emitted a `gen_ai.execute_tool` span per tool invocation with `gen_ai.tool.name`, `gen_ai.tool.call.id`, and `gen_ai.tool.call.arguments` as a JSON string. A downstream resume path read the last N spans from the collector to rebuild conversation state after a cold start. Three failure traces appeared: 1. **Argument truncation.** A `write_file` call carried a 41 KB payload. The exporter applied a configured attribute-value limit and truncated `gen_ai.tool.call.arguments` mid-string. On replay, the JSON string was syntactically invalid; a lenient parser recovered a *prefix* of the content and the agent resumed as if the file had been written with partial contents. The span's `status` was `OK`—truncation is not an error condition in the span model. 2. **Sampling gaps.** The collector used tail-based sampling that kept error spans and a fraction of success spans. A successful `send_email` tool call was dropped; the subsequent `gen_ai.chat` span that referenced its result survived. Reconstruction produced a tool result with no originating call, and the agent's planner re-issued the email. 3. **Redaction drift.** A scrubbing processor replaced `gen_ai.tool.call.arguments` values matching an email regex with `[REDACTED]`. The replay path, unable to distinguish "argument was literally `[REDACTED]`" from "argument was scrubbed," passed the sentinel into the next tool call. In all three cases the runtime's own trace was intact; only the telemetry projection was corrupted. The failure was entirely in the assumption that the projection equals the trace. ## Condition of Validity Treating `gen_ai.*` span attributes as authoritative for tool-call reconstruction is valid **only** when all of the following hold simultaneously: - The exporter is configured with attribute limits that provably exceed the maximum tool-argument and tool-result size the agent can produce (i.e., the limit is a hard invariant enforced at emission, not a default). - The span pipeline has **no** tail- or head-based sampling applied to `gen_ai.execute_tool` spans, or the replay path consumes a side-channel that is sampling-invariant. - No redaction/scrubbing processor mutates `gen_ai.tool.call.arguments` or `gen_ai.tool.call.result`, or scrubbing is *marked* (e.g., a companion `redaction.applied=true` attribute) so the replay path can detect it. - `gen_ai.tool.call.id` is preserved end-to-end and is the join key, not positional ordering of spans (span export order is not guaranteed causal order across batches). If any condition fails, the projection is a *hint*, not a *record*. The correct pattern is to persist the authoritative tool-call record in the agent's own state store and use spans only to correlate and visualize—never to reconstruct executable arguments. ## Decision Boundary The instance must draw the boundary at the **tool-call boundary**, not at the span boundary. Concretely: - **Reconstruct from spans** only for read-only, idempotent, size-bounded tools (e.g., `get_weather`) where a lossy replay is harmless. - **Refuse to reconstruct** from spans for any tool whose arguments are user-data-sized, whose result feeds a subsequent side effect, or whose call is non-idempotent (`send_*`, `write_*`, `delete_*`, `transfer_*`). For these, the replay path must read from the runtime's durable checkpoint keyed by `gen_ai.tool.call.id`, and must *fail closed* if the checkpoint is absent rather than falling back to span attributes. - **Detect the boundary** by checking, per span, whether the emitted argument length equals the runtime's recorded argument length and whether a redaction marker is present. A mismatch is the signal that the projection is lossy. The invariant: *a tool call may be re-executed from telemetry only if the telemetry is provably lossless for that call; otherwise re-execution requires the authoritative checkpoint, and its absence is a hard error, not a degraded mode.* ## Operational Effect Enforcing this boundary converts three silent corruptions into one loud, catchable failure. The agent stops re-sending emails and stops resuming with truncated file writes; instead the resume path raises a specific error and halts for operator intervention or checkpoint recovery. The cost is that cold-start resume now depends on a durable store keyed by `gen_ai.tool.call.id`—a small, well-defined dependency—rather than on the collector, which was never designed to be a system of record. Telemetry remains valuable for correlation and latency, but is demoted from *source of truth* to *index into the source of truth*. ```python import json from dataclasses import dataclass class LossyTelemetryError(RuntimeError): """Raised when span attributes cannot faithfully reconstruct a tool call.""" pass @dataclass class ToolSpan: call_id: str tool_name: str arguments_json: str # as emitted to the collector recorded_arg_len: int # authoritative length from runtime redacted: bool sampled_out: bool SIDE_EFFECT_PREFIXES = ("send_", "write_", "delete_", "transfer_", "post_") def reconstruct_tool_call(span: ToolSpan, checkpoint_store: dict) -> dict: # 1. Sampling gap: the call never reached the collector intact. if span.sampled_out: raise LossyTelemetryError( f"tool call {span.call_id} was sampled out; spans are not authoritative" ) # 2. Redaction drift: arguments were scrubbed in-flight. if span.redacted: raise LossyTelemetryError( f"tool call {span.call_id} arguments were redacted; cannot replay" ) # 3. Truncation: emitted length diverges from recorded length. if len(span.arguments_json) != span.recorded_arg_len: raise LossyTelemetryError( f"tool call {span.call_id} arguments truncated " f"({len(span.arguments_json)} != {span.recorded_arg_len})" ) # 4. Non-idempotent tools require the authoritative checkpoint, always. if span.tool_name.startswith(SIDE_EFFECT_PREFIXES): ckpt = checkpoint_store.get(span.call_id) if ckpt is None: raise LossyTelemetryError( f"no authoritative checkpoint for side-effecting call {span.call_id}; " f"refusing to reconstruct from telemetry" ) return ckpt # 5. Only here is the span projection safe to use. return {"call_id": span.call_id, "args": json.loads(span.arguments_json)} ```