{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-gen-ai-usage-input-tokens-on-an-agent-span-as-non-authoritative-for-cost-accounting",
  "title": "Under what conditions must an instance treat `gen_ai.usage.input_tokens` on an agent span as non-authoritative for cost accounting",
  "date_of_record": "2026 November 17",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (v1.27+ / experimental `gen_ai.*` namespace) emitted by agent runtimes that produce `invoke_agent`, `execute_tool`, and nested chat spans. Does not apply to single-shot chat completions without tool loops, nor to provider-native billing exports used as a source of truth.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-gen-ai-usage-input-tokens-on-an-agent-span-as-non-authoritative-for-cost-accounting.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-gen-ai-usage-input-tokens-on-an-agent-span-as-non-authoritative-for-cost-accounting.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-gen-ai-usage-input-tokens-on-an-agent-span-as-non-authoritative-for-cost-accounting.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1617,
    "python_slice_tokens": 297,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *per-span* counters describing the token volume attributable to that span's own model interaction. They are **not** defined as additive across a span tree, and they are **not** defined as exclusive of prompt-cache reads or of re-transmitted conversation history. For ...",
    "what_was_observed": "On a production agent trace (LangGraph-style orchestrator emitting OTel GenAI spans, provider = a major hosted API), a single user turn produced the following span tree: - `invoke_agent` (root): `gen_ai.usage.input_tokens = 1840`, `gen_ai.usage.output_tokens = 212` - `chat` (child, planning): `input_tokens = 41200`, `output_tokens = 640` - `execute_tool` × 6 (children): no usage attributes at all - `chat` (child, per...",
    "condition_of_validity": "The following invariants hold, and only these: 1. `gen_ai.usage.input_tokens` on a `chat` span is valid as the input token count *for that single model call*, provided the span was not dropped and the emitter is not a caching proxy that reports cache hits as zero. 2. `gen_ai.usage.input_tokens` on an `invoke_agent` span is valid **only** as \"tokens attributa...",
    "decision_boundary": "Treat trace-derived token sums as **authoritative for cost** if and only if *all* of the following hold: the agent service uses `AlwaysOn` sampling; the emitter is documented as non-rolling-up; every LLM call (including inside tools) is wrapped in a `chat` span; and prompt caching is either disabled or the emitter reports cache-read tokens in a separate attr...",
    "operational_effect": "The practical consequence is that a cost dashboard built on `sum(gen_ai.usage.input_tokens) by trace_id` will silently misreport by 2× on roll-up emitters and by 0.5× on fan-out emitters, and the error is invisible because the numbers are plausible. The correct posture is to tag each emitter with a known roll-up policy at instrumentation time, compute cost f..."
  },
  "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": "73788b2a24d793321b056286a21735bc94e75a92225f1383ea82ffc21dd0bc98",
    "verified_classes": [
      "TokenAccountingInvariantError",
      "EmitterPolicy"
    ],
    "verified_functions": [
      "cost_authoritative_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "TokenAccountingInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "sampled trace: token sums are a sample, not a ledger",
      "tool-internal LLM calls lack chat spans; tokens are invisible",
      "cache reads not separated; input_tokens understates billed input"
    ],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
