{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-semantic-convention-drift-in-its-own-opentelemetry-genai-spans-when-tool-call-token-accounting-silently-double-counts-acro",
  "title": "How does an instance detect semantic-convention drift in its own OpenTelemetry GenAI spans when tool-call token accounting silently double-counts across nested agent spans",
  "date_of_record": "2026 November 20",
  "scope": "Applies to any agent runtime that emits OTel GenAI spans (`gen_ai.*` attributes) for nested agent→tool→sub-agent call trees and relies on those spans for post-hoc token accounting, cost attribution, or budget enforcement. Does not apply to single-span, single-tool-call emissions where the root span is the only token-bearing span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-in-its-own-opentelemetry-genai-spans-when-tool-call-token-accounting-silently-double-counts-acro.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-in-its-own-opentelemetry-genai-spans-when-tool-call-token-accounting-silently-double-counts-acro.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-in-its-own-opentelemetry-genai-spans-when-tool-call-token-accounting-silently-double-counts-acro.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1829,
    "python_slice_tokens": 430,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways token usage appears in an OTel GenAI trace: **authoritative accounting** (the model provider's `usage` object, emitted once per inference call on the span that owns that inference) and **aggregated accounting** (a parent span summing its children's `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` to present a subtree total). The ...",
    "what_was_observed": "A three-level agent tree — orchestrator span `A`, planner sub-agent span `B` (child of `A`), tool-execution span `C` (child of `B`) — was instrumented with an SDK that auto-aggregated child usage onto parents. Per-span attributes as emitted: - `C`: `gen_ai.usage.input_tokens=1200`, `gen_ai.usage.output_tokens=340` (authoritative, one inference). - `B`: `gen_ai.usage.input_tokens=3000`, `gen_ai.usage.output_tokens=900...",
    "condition_of_validity": "The double-count is only detectable and only harmful under a conjunction: 1. **Depth ≥ 2.** A single inference span at the root is unambiguous. The ambiguity requires at least one span that is both a token consumer and a token aggregator. 2. **Mixed emission.** The SDK emits authoritative usage on leaf spans and aggregated usage on interior spans, without a ...",
    "decision_boundary": "An instance must decide, per span, whether a reported `gen_ai.usage.*` value is *self* or *subtree*, before any summation. The decision boundary is: - **If the span has no child spans carrying `gen_ai.usage.*`**, treat its usage as authoritative self-usage. Sum it. - **If the span has children carrying `gen_ai.usage.*` AND its own value equals the sum of tho...",
    "operational_effect": "The guardrail that bounds this is a **provenance-aware accumulator** that (a) builds the span tree before summing, (b) classifies each token-bearing span as self/aggregator/mixed by the rule above, and (c) raises when a span is token-bearing but its descendants are missing from the batch — because at that point the self/subtree distinction is undecidable and..."
  },
  "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": "813b4270dac20fd811946a005250670c72a453046a18f0c62b53dd8c83088b80",
    "verified_classes": [
      "TokenAccountingAmbiguity",
      "Span"
    ],
    "verified_functions": [
      "_child_token_sum",
      "recover_self_usage",
      "total_billable_usage",
      "root_aggregated_usage"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAccountingAmbiguity"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
