{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-span-attribute-truncation-is-corrupting-token-accounting-in-opentelemetry-genai-agent-traces",
  "title": "What structural signals indicate span-attribute truncation is corrupting token accounting in OpenTelemetry GenAI agent traces",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans per the GenAI semantic conventions (`gen_ai.*` attributes) where tool-call arguments/results and token usage are recorded as span attributes. Does not address metrics-only pipelines, log-based telemetry, or non-conformant custom attribute schemes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-truncation-is-corrupting-token-accounting-in-opentelemetry-genai-agent-traces.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-truncation-is-corrupting-token-accounting-in-opentelemetry-genai-agent-traces.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-truncation-is-corrupting-token-accounting-in-opentelemetry-genai-agent-traces.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1718,
    "python_slice_tokens": 413,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) and tool-call payloads (`gen_ai.tool.call.arguments`, `gen_ai.tool.call.result`) as *span attributes*—flat key/value strings attached to the span at emission time. The distinction that matters operationally is between **truncation as a display concern...",
    "what_was_observed": "A multi-step agent performing retrieval-augmented tool calls emitted spans where `gen_ai.usage.input_tokens` reported ~1,800 tokens per turn, but the orchestrator's own context-window meter showed ~7,400 tokens on the same turns. The ratio was stable at roughly 0.24 across hundreds of spans—too consistent to be noise. Tracing the emission path revealed the mechanism: 1. The tool returned a 42 KB JSON document. The ag...",
    "condition_of_validity": "The invariant \"span token counters reflect the model's true context cost\" holds **only if** the attribute value used to compute the counter is byte-identical to the payload submitted to the model *and* the attribute survived serialization without clipping. It is violated whenever: - Any per-attribute byte cap exists in the SDK, collector, or backend, **and**...",
    "decision_boundary": "The operational decision is whether to treat a clipped tool-call attribute as a *telemetry cosmetic* or as a *correctness fault requiring span invalidation*. The boundary condition: - If `gen_ai.tool.call.result` byte length equals the configured cap **and** the value fails the tool's declared output schema **and** the span's `input_tokens` does not reconcil...",
    "operational_effect": "When the boundary is mis-classified, three downstream effects compound: 1. **Cost attribution under-reports context growth.** Because clipped spans under-count, the agent's context-window saturation is invisible in telemetry until the model provider returns a hard context-limit error—the exact failure the trace was supposed to predict. 2. **Distillation loss..."
  },
  "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": "241b396d9a3d1eb2e84871b58a001cb136538eab210b84b1d4808f075d06d77e",
    "verified_classes": [
      "TelemetryAccountingFault",
      "GenAISpan"
    ],
    "verified_functions": [
      "validate_span_for_accounting",
      "finalize_batch"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TelemetryAccountingFault"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
