{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-a-genai-agent-span-s-token-accounting-as-authoritative-across-tool-call-boundaries",
  "title": "Under what conditions must an instance treat a GenAI agent span's token accounting as authoritative across tool-call boundaries",
  "date_of_record": "2026 November 18",
  "scope": "Applies to OpenTelemetry instrumentation of LLM agent loops that emit `gen_ai.*` spans with nested tool-call spans and accumulate `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`. Does not apply to single-shot completion calls with no tool dispatch, nor to provider-side billing reconciliation, which uses a different source of truth.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-agent-span-s-token-accounting-as-authoritative-across-tool-call-boundaries.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-agent-span-s-token-accounting-as-authoritative-across-tool-call-boundaries.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-agent-span-s-token-accounting-as-authoritative-across-tool-call-boundaries.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1325,
    "python_slice_tokens": 252,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a persistent confusion between *span-local usage* and *run-cumulative usage*. The GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a single inference span — the tokens consumed by *that* model invocation. They are not, and were never specified to be, additive across a parent agent span t...",
    "what_was_observed": "A multi-agent orchestration emitted a parent `invoke_agent` span with three children: two `chat` inference spans and one `execute_tool` span that itself dispatched a sub-agent (which emitted its own `invoke_agent` → `chat` chain). The exporter's span processor computed parent usage by summing all descendants with `gen_ai.usage.input_tokens` present. Observed result: parent `input_tokens` = 41,882. Ground truth from p...",
    "condition_of_validity": "Treat a usage attribute as authoritative **if and only if** all of the following hold: 1. The attribute is present on a span whose `gen_ai.operation.name` is a model-invocation operation (`chat`, `text_completion`, `embeddings`, or a provider-namespaced equivalent) — not on `execute_tool` or an agent container. 2. The span has no descendant span that also ca...",
    "decision_boundary": "The boundary is *span ownership*, not span nesting. A parent agent span does **not** own its children's token counts. It owns only the tokens of inference calls it directly initiated. The decision to aggregate is a presentation choice; the decision to *authorize* aggregation as truth is a correctness choice. Concretely: if you find yourself summing `gen_ai.u...",
    "operational_effect": "Downstream consumers (cost allocators, rate limiters, anomaly detectors) keyed on `gen_ai.usage.*` will over-count in proportion to agent nesting depth. Because nesting depth correlates with task complexity, the error masquerades as a workload signal. Rate limiters that budget against these totals will throttle complex agents earlier than simple ones — an em..."
  },
  "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": "f94300d84fefb12ead53d8278516ec2f6c3b4284941e3b179abea98588ffd663",
    "verified_classes": [
      "NonAuthoritativeUsageError",
      "Span"
    ],
    "verified_functions": [
      "aggregate_authoritative_usage",
      "has_usage"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "NonAuthoritativeUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
