# What structural signals indicate span-attribute truncation has silently corrupted GenAI tool-call lineage across an OTel-instrumented agent handoff **Date of Record:** 2026 November 29 **Scope:** Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes) where tool-call arguments/results and agent handoff payloads are recorded as span attributes and reconstructed downstream by an auditor, replay engine, or cost/lineage aggregator. Does not apply to systems that emit full payloads out-of-band via span links or log events with no attribute-size ceiling. ## Core Distinction The GenAI semantic conventions treat a tool call as a span with structured attributes: `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, and — critically for lineage — the arguments and result, conventionally serialized into `gen_ai.tool.call.arguments` / `gen_ai.tool.call.result` (or captured via `gen_ai.tool.message` events). The boundary failure is **not** that a span is dropped. It is that the OTel SDK/collector enforces a per-attribute value-length limit (default `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`, commonly 1024–4096 bytes, and `OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT` on cardinality) and **truncates the attribute value in place while still emitting the span**. The span remains valid, the `call.id` survives, the parent/child linkage is intact — so every structural health check passes. What is destroyed is the *content* of the tool invocation, and because truncation is applied independently per span and per attribute, a downstream consumer that reassembles a multi-hop agent trajectory from attributes sees well-formed but semantically broken lineage. The distinction that matters: a *missing* span is detectable (gap in trace, orphaned `call.id`); a *truncated* span is indistinguishable from a complete one at the schema level. The failure is a silent content-loss invariant violation masquerading as a healthy trace. ## What Was Observed A two-agent handoff pipeline (planner → executor) invoked a `read_file` tool whose arguments included a ~6 KB JSON object (a schema plus a base64 blob). The collector was configured with the default `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=1024`. Observed sequence: 1. The tool-call span emitted with `gen_ai.tool.call.arguments` truncated to 1024 bytes. The truncation was *not* marked — no `…truncated` suffix, no companion `*.truncated=true` attribute. The value simply ended mid-token, producing invalid JSON in the attribute. 2. The `gen_ai.tool.call.result` attribute carried the *full* result (under limit), so the span looked "half-populated" but structurally normal. 3. The agent-handoff span (`gen_ai.operation.name=invoke_agent`, `gen_ai.agent.name=executor`) referenced the tool span via a span link, but the handoff's own `gen_ai.agent.handoff.context` attribute — which serialized the planner's summarized state — was independently truncated at 1024 bytes, cutting off the trailing `pending_tool_calls` array. 4. Downstream, a replay/audit service parsed `gen_ai.tool.call.arguments` as JSON, hit a parse error, and — because its parser had a permissive fallback — treated the argument object as `{}` and continued. The replay reconstructed a tool call with *empty arguments* that nonetheless had a valid `call.id` and a real result. The lineage graph showed a coherent edge where none semantically existed. 5. The auditor's cross-check (does the replayed argument hash match the recorded argument hash?) compared hashes of *truncated* strings on both sides and therefore matched. The corruption was self-consistent. The signal that eventually surfaced it was not a trace-health metric but a semantic one: the executor's next span referenced a field (`blob_offset`) that could only have come from the truncated tail of the handoff context, proving the truncation boundary had fallen inside a live control field rather than inside a payload field. ## Condition of Validity The invariant "a span with a valid `gen_ai.tool.call.id` and intact parent linkage carries faithful call content" holds **only if** every attribute that participates in lineage reconstruction is either (a) below the configured value-length limit, or (b) accompanied by an explicit truncation marker and a retrievable full-payload reference (span link, log event, or blob store key). It is violated whenever: - The serialized arguments/result/context exceed `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` **and** the emitting SDK truncates silently (the common default), **and** - A downstream consumer treats attribute presence + parse success as a content-integrity signal. It does **not** apply when payloads are emitted as span *events* with `OTEL_*_LIMIT` disabled, or when the instrumentation uses `gen_ai.tool.call.id` as a join key into an out-of-band store that is verified against a length/hash attribute. The condition of validity is therefore: **lineage faithfulness is bounded by the minimum of the attribute-length limit and the largest lineage-bearing attribute, unless a truncation sentinel is present.** ## Decision Boundary The operative decision is whether to trust a span's attribute content as ground truth for lineage. The boundary is crossed at the point where: ``` serialized_len(attr) >= OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT AND no companion attr {attr}_truncated == true AND consumer does not re-derive content from a linked source ``` When this predicate is true, the span is in the **untrusted-content / trusted-structure** regime: linkage (`call.id`, parent span id, links) may be used, but attribute *values* must not be parsed as authoritative. The correct decision at this boundary is to **fail the lineage reconstruction closed** — mark the edge as `content_unverified` — rather than fall back to `{}` or a permissive parse. A permissive fallback converts a detectable truncation into an undetectable semantic corruption, which is strictly worse because it defeats the hash-equality cross-check (both sides hash the same truncated bytes). ## Operational Effect Silent truncation inverts the normal failure economics of distributed tracing. Ordinarily, missing data is loud (gaps, orphans) and corrupt data is rare. Here, corrupt data is silent and *self-consistent*, so replay and audit agree with each other and with the trace, and the only remaining detector is a semantic cross-reference (a downstream field that could only originate from a truncated tail). Operationally this means: - Attribute-length limits must be treated as a **lineage-integrity parameter**, not a cost knob. Lowering it to save collector memory silently narrows the set of reconstructable trajectories. - Instrumentation must emit an explicit truncation sentinel and a stable content hash per lineage-bearing attribute, so consumers can detect `hash(recorded) != hash(reconstructed)` even when both are truncated. - Replay/audit code must fail closed on parse error for lineage attributes — never `{}` fallback — because the fallback is what launders truncation into plausible-looking lineage. The guardrail that bounds the failure: **any attribute used to reconstruct agent state must carry a truncation bit and a content digest, and any consumer must verify the digest before treating the attribute as ground truth.** Without the digest, the trace is structurally sound and semantically unreliable, and no span-level metric will tell you which. ```python import hashlib import json from typing import Any class LineageTruncationError(RuntimeError): """Raised when a GenAI lineage-bearing span attribute is truncated or fails digest verification, so lineage reconstruction must fail closed.""" def reconstruct_tool_call(span_attrs: dict[str, Any]) -> dict[str, Any]: call_id = span_attrs.get("gen_ai.tool.call.id") if not call_id: raise LineageTruncationError( "span missing gen_ai.tool.call.id; cannot anchor lineage" ) raw_args = span_attrs.get("gen_ai.tool.call.arguments") recorded_digest = span_attrs.get("gen_ai.tool.call.arguments.digest") truncated = span_attrs.get("gen_ai.tool.call.arguments.truncated", False) if raw_args is None: raise LineageTruncationError( f"call {call_id}: arguments attribute absent, not reconstructable" ) if truncated: # A truncation sentinel means the value is known-incomplete. # Fail closed rather than parse a partial payload. raise LineageTruncationError( f"call {call_id}: arguments flagged truncated; " "content is untrusted, refuse to parse" ) if recorded_digest is None: # No digest means we cannot distinguish complete from silently # truncated content. Structural validity is not content validity. raise LineageTruncationError( f"call {call_id}: no content digest; truncation status unknowable" ) actual_digest = hashlib.sha256(raw_args.encode("utf-8")).hexdigest() if actual_digest != recorded_digest: raise LineageTruncationError( f"call {call_id}: digest mismatch " f"(recorded={recorded_digest[:12]} actual={actual_digest[:12]}); " "attribute content diverged from emission" ) try: args = json.loads(raw_args) except json.JSONDecodeError as exc: # Do NOT fall back to {} — that launders corruption into lineage. raise LineageTruncationError( f"call {call_id}: arguments not valid JSON despite digest match: {exc}" ) from exc return {"call_id": call_id, "arguments": args, "verified": True} ```