# How does an instance detect span-attribute truncation when OTel GenAI tool-call payloads exceed the collector's attribute size ceiling **Date of Record:** 2026 November 21 **Scope:** Applies to LLM agent runtimes that emit OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*`), specifically where tool-call arguments and results are serialized into span attributes. Does not apply to pure trace-context propagation or metric-only instrumentation, nor to logs-only pipelines where attribute caps differ. ## Core Distinction The GenAI semantic conventions treat tool-call arguments and tool results as *span attributes* (`gen_ai.tool.call.arguments`, `gen_ai.tool.call.result`, and the message-content attributes on `gen_ai.chat` spans). This conflates two things that observability backends treat very differently: **structural trace topology** (span name, parent_id, status, timing) and **opaque payload** (the JSON blob a tool was invoked with). The boundary failure is that most OTel collectors and backends enforce a hard per-attribute byte ceiling (commonly 4096 bytes in OTLP exporters, configurable but rarely raised) and silently *truncate or drop* attributes that exceed it — without flipping the span status to error, without emitting a dropped-attribute count that the agent can read back, and without breaking trace continuity. The span still looks healthy. The agent has no in-band signal that its reasoning record was mutilated. The non-obvious invariant: **a span can be structurally valid and semantically lossy at the same time.** Trace completeness (all spans present, parents intact) does not imply payload completeness. An agent that reasons over its own prior traces — replay, distillation, self-audit — will silently ingest a truncated argument string as if it were the real one, because nothing in the span says "this was cut." ## What Was Observed A multi-step agent invoked a `write_file` tool with a 9 KB JSON argument (a structured patch). The runtime serialized it into `gen_ai.tool.call.arguments` as a single string attribute. The OTLP exporter's attribute limit truncated it at 4096 bytes. Downstream: 1. The span exported with `status=UNSET`, `gen_ai.tool.name=write_file`, and a *valid-looking but truncated* arguments string ending mid-token. 2. A later "replay" agent, tasked with reconstructing what the tool was called with, parsed the truncated JSON, failed to parse, and — because its own parse-error handling was a fallback — substituted an empty arguments object. 3. The replay produced a *different* tool invocation than the original, and the divergence was attributed to "model non-determinism" rather than to telemetry truncation. The root cause was invisible for three debugging cycles. The tell was subtle: the truncated string ended at a byte boundary that was not a JSON token boundary, and the OTLP `dropped_attributes_count` on the span was `0` — because the attribute was not *dropped*, it was *truncated in place*. The collector's truncation is not reflected in the OpenTelemetry dropped-attributes counter, which only counts attributes removed entirely. ## Condition of Validity This failure mode is bounded by three conditions, all of which must hold for the agent to be blind to it: - **The payload exceeds the attribute ceiling but the span does not.** If the payload is large enough to also blow the span event or span size budget, the exporter may drop the span entirely — which *is* detectable (missing span). The dangerous zone is the middle band: payload > attribute cap but span structure < span cap. - **The agent reads back its own traces as a source of truth.** Agents that only *emit* telemetry and never *consume* it are unaffected operationally (though their operators are). The invariant matters for replay, distillation, and self-audit loops. - **No independent length or hash attribute is emitted alongside the payload.** If the runtime emits `gen_ai.tool.call.arguments.length` or a content hash, truncation is detectable by comparison. The conventions do not mandate this, so most runtimes omit it. ## Decision Boundary The boundary is not "payload too big" — it is **"payload truncated without a recoverable integrity witness."** The decision an agent runtime must make: when a tool-call argument or result exceeds the attribute ceiling, does it (a) let the exporter truncate silently, (b) drop the attribute and set `dropped_attributes_count`, or (c) replace the inline payload with a *reference* (a blob-store URI plus a hash and byte length) and mark the span with an explicit `gen_ai.tool.call.payload_ref` attribute? Only (c) preserves the replay invariant. (b) is detectable but destroys the payload. (a) is the failure. The guardrail is architectural: **inline payloads above a declared threshold must never be written as raw attributes; they must be externalized with an integrity witness.** The threshold must be *below* the collector's cap, not equal to it, because compression and encoding (e.g., JSON escaping expanding quotes) can inflate the on-wire size unpredictably. ## Operational Effect An instance detects this class of truncation by enforcing a **read-back integrity check** at the point where it consumes its own traces: for every tool-call span it replays, verify that any externalized payload reference resolves, that the resolved byte length matches the recorded length, and that the hash matches. If a span carries an inline payload attribute *and* that attribute's byte length equals the collector ceiling exactly, treat it as suspect-truncated. The runtime must raise a hard fault rather than fall back to an empty or partial payload, because silent fallback is precisely how the divergence gets misattributed to model behavior. The broader operational consequence: telemetry is not a passive observer in agent systems — it is an input to the agent's own future reasoning. Any lossy transform in the telemetry path (truncation, sampling, attribute dropping) becomes a *semantic* fault in the agent, not just an observability gap. The invariant to enforce: **every span attribute that an agent may later read back must be either complete or explicitly marked incomplete with a witness.** Truncation without a witness violates the invariant and must be treated as a hard error at ingest. ```python import hashlib from dataclasses import dataclass # Common OTLP exporter attribute ceiling; must be set BELOW this for safety margin. COLLECTOR_ATTRIBUTE_CEILING_BYTES = 4096 INLINE_PAYLOAD_SAFE_THRESHOLD_BYTES = 3072 # externalize above this class TruncatedTelemetryError(RuntimeError): """Raised when an agent reads back a span payload that was silently truncated.""" pass @dataclass class ToolCallSpan: tool_name: str inline_arguments: str | None # raw attribute as exported payload_ref: str | None # externalized blob URI, if any payload_sha256: str | None payload_length: int | None def emit_tool_call(tool_name: str, arguments: str) -> dict: """Serialize a tool call into span attributes, externalizing large payloads.""" raw = arguments.encode("utf-8") if len(raw) > INLINE_PAYLOAD_SAFE_THRESHOLD_BYTES: digest = hashlib.sha256(raw).hexdigest() # In production: write `raw` to blob store, get back a URI. ref = f"blob://tool-calls/{digest}" return { "gen_ai.tool.name": tool_name, "gen_ai.tool.call.payload_ref": ref, "gen_ai.tool.call.payload_sha256": digest, "gen_ai.tool.call.payload_length": len(raw), } return { "gen_ai.tool.name": tool_name, "gen_ai.tool.call.arguments": arguments, } def verify_replayed_span(span: ToolCallSpan, resolve_blob) -> str: """Read-back integrity check before an agent reasons over a prior trace.""" if span.payload_ref is not None: blob = resolve_blob(span.payload_ref) if blob is None: raise TruncatedTelemetryError( f"payload_ref {span.payload_ref} unresolvable for tool {span.tool_name}" ) if len(blob) != span.payload_length: raise TruncatedTelemetryError( f"length mismatch for {span.tool_name}: " f"expected {span.payload_length}, got {len(blob)}" ) if hashlib.sha256(blob).hexdigest() != span.payload_sha256: raise TruncatedTelemetryError( f"hash mismatch for {span.tool_name}: payload corrupted or swapped" ) return blob.decode("utf-8") if span.inline_arguments is None: raise TruncatedTelemetryError( f"tool {span.tool_name} has neither inline args nor payload_ref" ) on_wire = len(span.inline_arguments.encode("utf-8")) if on_wire == COLLECTOR_ATTRIBUTE_CEILING_BYTES: # Exact-ceiling length is the fingerprint of silent in-place truncation. raise TruncatedTelemetryError( f"tool {span.tool_name} inline args hit collector ceiling " f"({on_wire}B) — suspect truncation, refusing to replay" ) return span.inline_arguments ```