{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-span-attribute-cardinality-explosion-from-silently-truncating-tool-call-lineage-in-agent-traces",
  "title": "Which invariants prevent span-attribute cardinality explosion from silently truncating tool-call lineage in agent traces",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents emitting OpenTelemetry GenAI spans (`gen_ai.*`) where one logical turn fans out into many `execute_tool` child spans. Does not apply to single-shot completions with no tool calls, nor to trace backends that enforce unbounded attribute length.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-cardinality-explosion-from-silently-truncating-tool-call-lineage-in-agent-traces.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-cardinality-explosion-from-silently-truncating-tool-call-lineage-in-agent-traces.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-cardinality-explosion-from-silently-truncating-tool-call-lineage-in-agent-traces.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1825,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a *span* as the unit of accounting and *attributes* as scalar facts about that span. Neither abstraction was designed for the case where a single agent turn produces a fan-out whose cardinality is itself a runtime decision made by the model. The distinction that matters operationally is between **cardinality of spans** (b...",
    "what_was_observed": "A research agent with a 40-iteration loop was instrumented to emit, on the root `gen_ai.agent.turn` span, a `gen_ai.tool.call.lineage` attribute: a JSON-serialized list of every tool invocation in the turn, each entry `{\"call_id\": ..., \"tool\": ..., \"parent\": ...}`. The SDK was configured with `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT=8192` (a common default in vendor distros). Average turn: 12 tool calls, ~1.4 KB of lineage...",
    "condition_of_validity": "The guardrail below is valid only under these conditions, stated explicitly so that it does not become cargo-culted: 1. **The lineage is derivable from span structure.** If each tool call is already a child span with `gen_ai.tool.name` and a `call_id` attribute, the parent-span lineage string is *redundant* and should be removed, not truncated-guarded. The i...",
    "decision_boundary": "The boundary is a single rule: **any attribute whose value is a variable-length encoding of runtime-decided cardinality must carry an explicit completeness marker, or it must not be exported.** Concretely, at serialization time: - Compute the serialized lineage and compare its length against `min(OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, backend_max_attribute_bytes...",
    "operational_effect": "Applying the completeness marker changed incident behavior in three measurable ways. First, the replay tool stopped reporting early termination: it now checks `complete` and, when false, reconstructs from child spans, producing the correct 38-call graph. Second, the `omitted` count became a first-class metric — turns routinely omitting lineage are a signal t..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "20eb44da196d274d2fe3f3515c7ab51df66d657d8b0f5732bfb2ae7ac997e255",
    "verified_classes": [
      "LineageTruncationError"
    ],
    "verified_functions": [
      "encode_lineage"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "LineageTruncationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
