{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-span-attribute-divergence-when-opentelemetry-genai-token-accounting-is-reconciled-against-agent-tool-call-spans",
  "title": "What structural signals indicate span-attribute divergence when OpenTelemetry GenAI token accounting is reconciled against agent tool-call spans",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where token usage is attributed per-span and later reconciled against tool-call child spans. Does not apply to single-shot inference calls with no tool loop, or to backends that emit only root spans without per-tool instrumentation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-divergence-when-opentelemetry-genai-token-accounting-is-reconciled-against-agent-tool-call-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-divergence-when-opentelemetry-genai-token-accounting-is-reconciled-against-agent-tool-call-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-attribute-divergence-when-opentelemetry-genai-token-accounting-is-reconciled-against-agent-tool-call-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1582,
    "python_slice_tokens": 287,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *per-inference-operation* counters attached to a single span. The convention does not define how those counters compose when an agent executes a multi-turn tool loop in which each turn is a separate inference call but the loop is presented as one logical \"age...",
    "what_was_observed": "An agent loop instrumented with the GenAI conventions emitted, for a single task, a parent span `agent.run` with `gen_ai.usage.input_tokens=4820`, `gen_ai.usage.output_tokens=910`. Beneath it, four inference child spans (`gen_ai.operation.name=chat`) each carried their own `gen_ai.usage.*` attributes, and three of those spans had tool-call children (`gen_ai.operation.name=execute_tool`) with `gen_ai.tool.name` set bu...",
    "condition_of_validity": "The aggregate-vs-local divergence is only well-defined—and only safe to reconcile—when all of the following hold: 1. Every inference child span carries `gen_ai.operation.name=chat` and a complete `gen_ai.usage.*` triple (`input_tokens`, `output_tokens`, and ideally `total_tokens`). 2. The parent agent span, if it declares aggregate usage, sets an explicit ma...",
    "decision_boundary": "The operational decision is: **when parent and leaf token sums disagree, which do you trust for budgeting and cost?** - If the parent carries a `gen_ai.usage.scope=aggregate` marker and leaves sum to *less* than the parent, trust the parent for cost (it includes preamble) but trust the leaves for per-tool attribution. The gap is preamble, not loss. - If leav...",
    "operational_effect": "Teams that reconcile naively see a persistent 5–12% input-token undercount (the preamble gap) that they misdiagnose as tokenizer drift, and they see spurious \"clock skew\" alerts on every pipelined tool loop. Both are artifacts of applying span-local invariants to aggregate-semantics spans. The correct posture is: recompute cost from chat leaves, treat parent..."
  },
  "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": "7aa9247060e2d90878e7303c05dd5caf049c7a84f4ca88768305b9788c7d350c",
    "verified_classes": [
      "GenAIAccountingDivergence",
      "SpanUsage"
    ],
    "verified_functions": [
      "reconcile_agent_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAIAccountingDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
