{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-model-multi-turn-agent-tool-call-trees",
  "title": "What structural signals indicate token-accounting drift when OpenTelemetry GenAI spans model multi-turn agent tool-call trees",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agents that emit OTel GenAI semantic-convention spans (`gen_ai.*`) across multi-turn, nested tool-call trees where a single logical turn fans out into child `execute_tool` and nested `chat` spans. Does not apply to single-shot inference calls with flat span hierarchies, nor to providers that report usage at the request level only without per-turn attribution.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-model-multi-turn-agent-tool-call-trees.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-model-multi-turn-agent-tool-call-trees.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-drift-when-opentelemetry-genai-spans-model-multi-turn-agent-tool-call-trees.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1545,
    "python_slice_tokens": 359,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a *single* model invocation span. They deliberately do **not** define an aggregation rule across a span tree. This is the load-bearing gap: the convention specifies per-span truth but leaves tree-level token accounting undefined. Operators ther...",
    "what_was_observed": "A three-hop tool-call turn (plan → search → synthesize) produced the following span tree: Naive summation yields `input = 5,406`, `output = 740`. The provider invoice for the turn showed `input = 2,910` (the final, longest context is the only distinct prefix the model was billed for under prefix caching) and `output = 740`. The tree-sum overcounted input by 86%. The structural signal is the **monotonically increasing...",
    "condition_of_validity": "Tree-summation of `gen_ai.usage.*` is valid **only** when all three hold: 1. Every `chat` span in the trace has a *disjoint* input prefix — i.e., `input_tokens` does not grow monotonically along the continuation chain. This is the stateless regime. 2. No `chat` span is a continuation of a sibling, detectable by checking that `input_tokens[i] < input_tokens[i...",
    "decision_boundary": "The boundary is crossed at the moment an agent emits a *continuation* `chat` span whose `input_tokens` exceeds the parent's `input_tokens + output_tokens` by more than the tool result payload. Below that threshold, the span is a fresh independent call and summation is safe. Above it, the span is a continuation and summation double-counts. Operationally: comp...",
    "operational_effect": "An aggregator that sums without this check produces token dashboards that overcount agentic turns by 50–200% while undercounting stateless turns by the tool-span gap. The two errors partially cancel in mixed workloads, which is why the drift survives review: aggregate cost looks plausible while per-turn attribution is wrong in both directions. The fix is to ..."
  },
  "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": "47357f62ab6fde8ab3b85bc866e24a2e73af64d758abde32ba41eafecfb77153",
    "verified_classes": [
      "SpanTreeAccountingError",
      "ChatSpan"
    ],
    "verified_functions": [
      "attribute_turn"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanTreeAccountingError"
    ],
    "sample_fail_closed_invariants": [
      "empty continuation chain"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
