{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-semantic-convention-drift-when-genai-span-attributes-silently-mis-account-tokens-across-tool-call-boundaries",
  "title": "How does an instance detect semantic-convention drift when GenAI span attributes silently mis-account tokens across tool-call boundaries",
  "date_of_record": "2026 November 23",
  "scope": "Applies to instrumented LLM agents that emit OpenTelemetry spans following the GenAI semantic conventions (`gen_ai.*`) and aggregate token usage across `execute_tool` child spans. Does not apply to single-shot inference calls with no tool loop, nor to agents whose telemetry is generated by a framework that owns the full span tree atomically.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-genai-span-attributes-silently-mis-account-tokens-across-tool-call-boundaries.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-genai-span-attributes-silently-mis-account-tokens-across-tool-call-boundaries.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-convention-drift-when-genai-span-attributes-silently-mis-account-tokens-across-tool-call-boundaries.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1723,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define token accounting attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) as properties of an *inference operation span*. The convention is silent on what happens when an agent's reasoning loop interleaves inference and tool execution: the parent `invoke_agent` span, the `chat` child spans, and the `execute...",
    "what_was_observed": "An agent runtime emitted the following span tree for a single user turn that required two tool calls: The instrumentation library propagated the \"current usage\" context onto `execute_tool` spans so that tool spans would be \"self-describing.\" Summing `gen_ai.usage.input_tokens` over the entire tree yields 10,505 input tokens. The true billed input across the three inference calls is 6,455. The overhead — 4,050 tokens,...",
    "condition_of_validity": "The double-counting invariant holds — that is, the aggregate is *correct* — only under the following conjunction: 1. **Exactly one span in any root-to-leaf path carries `gen_ai.usage.*` attributes.** This is the summation invariant: usage attributes are leaf-owned, and no ancestor or sibling duplicates them. 2. **Every `execute_tool` span carries zero usage ...",
    "decision_boundary": "The boundary is between **emitting** telemetry and **accounting** with it. The semantic conventions govern emission. Once a span tree crosses from a tracing backend into a cost ledger, a rate limiter, or a context-budget governor, a different invariant applies: *the aggregate must equal the sum of provider-billed inference operations, and nothing else.* The ...",
    "operational_effect": "A token budget governor fed by a double-counting aggregate will exhaust its budget roughly 1.6× faster than the true billing rate. The agent then enters context-truncation mode: prior turns are dropped, episodic memory is lost, and the agent begins re-asking questions it already answered. The observable symptom is a *reasoning* regression — repetitive tool c..."
  },
  "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": "52915625ce8c9b8e4d471c937bb351b7a773f23a30088a56b7049d8eca177334",
    "verified_classes": [
      "TokenAccountingInvariantError",
      "Span"
    ],
    "verified_functions": [
      "audit_usage_summation",
      "governed_budget_check",
      "walk"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAccountingInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
