{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-reports-genai-token-usage-across-a-span-boundary-that-the-otel-semantic-conventions-do-not-reconcile",
  "title": "What happens when an instance reports GenAI token usage across a span boundary that the OTel semantic conventions do not reconcile",
  "date_of_record": "2026 November 28",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) for inference, tool-call, and agent-orchestration spans, where token accounting is aggregated across nested spans by a downstream collector or cost-attribution pipeline. Does not apply to single-span, single-model deployments that emit usage on exactly one span per request, nor to non-OTel tracing backends with native token meters.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-across-a-span-boundary-that-the-otel-semantic-conventions-do-not-reconcile.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-across-a-span-boundary-that-the-otel-semantic-conventions-do-not-reconcile.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-across-a-span-boundary-that-the-otel-semantic-conventions-do-not-reconcile.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2000,
    "python_slice_tokens": 222,
    "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 on the span that *represents the model invocation*. They deliberately do not define an aggregation rule for parent agent spans that fan out to multiple child inference spans. This is a semantic gap, not a bug: the conventions describe what a singl...",
    "what_was_observed": "An agent runtime executing a three-step plan (classify → retrieve → synthesize) emitted the following span tree for a single user turn: - `agent.run` (root, agent orchestration span) - `gen_ai.chat` step 1 (classifier) — `gen_ai.usage.input_tokens=812`, `output_tokens=47` - `tool.retrieve` — no usage attributes (correct; tool spans do not invoke the model directly) - `gen_ai.chat` step 2 (synthesizer) — `gen_ai.usage...",
    "condition_of_validity": "The double-count is only observable — and only harmful — when all of the following hold: 1. At least one ancestor span in the trace carries `gen_ai.usage.*` attributes that duplicate values present on descendant spans. 2. A downstream consumer aggregates usage by summing across the span tree rather than selecting a single canonical span per invocation. 3. Th...",
    "decision_boundary": "The boundary is **where usage is allowed to be authoritative**. The conventions do not name an authoritative span, so the runtime must impose one. Two coherent policies exist, and mixing them is what produces the failure: - **Leaf-authoritative:** `gen_ai.usage.*` appears *only* on spans that represent an actual model invocation (`gen_ai.operation.name=chat`...",
    "operational_effect": "Under leaf-authoritative emission, cost dashboards that sum leaves are correct by construction, and per-step attribution survives. The cost is that a consumer wanting total-per-turn must walk the tree rather than read one attribute — a small, bounded cost paid once in the collector. Under root-authoritative emission, total-per-turn is a single attribute read..."
  },
  "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": "17e60807d8f9927dc4f1120923151469387625faccddc8a08fccf1ea706cba6e",
    "verified_classes": [
      "UsageAttributionError"
    ],
    "verified_functions": [
      "validate_usage_attribution",
      "aggregate_leaf_usage",
      "carries_usage",
      "ancestors"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "UsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
