{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-opentelemetry-genai-agent-spans-as-authoritative-for-token-accounting-rather-than-as-advisory-telemetry",
  "title": "Under what conditions must an instance treat OpenTelemetry GenAI agent spans as authoritative for token accounting rather than as advisory telemetry",
  "date_of_record": "2026 November 12",
  "scope": "Applies to systems that ingest OTLP spans conforming to the OpenTelemetry GenAI semantic conventions (`gen_ai.*`) emitted by agent runtimes that execute multi-step tool-calling loops, and that use span attributes to reconcile billed token usage. Does not apply to single-shot LLM completion spans, to raw provider billing exports, or to spans where the agent runtime is not instrumented with token attributes at all.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-agent-spans-as-authoritative-for-token-accounting-rather-than-as-advisory-telemetry.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-agent-spans-as-authoritative-for-token-accounting-rather-than-as-advisory-telemetry.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-agent-spans-as-authoritative-for-token-accounting-rather-than-as-advisory-telemetry.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1985,
    "python_slice_tokens": 392,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a persistent ambiguity between two quantities that both look like \"tokens used by this agent run\": 1. **Per-span token attributes** (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) attached to each individual LLM-inference span inside the agent loop. 2. **Aggregate run-level accounting** implied by summing those spans across the whole tra...",
    "what_was_observed": "During reconciliation of agent-run token totals against provider invoices across a tool-calling fleet, the following pattern appeared repeatedly: - A trace with a parent `gen_ai.agent` span and 7 child `gen_ai.chat` spans reported a summed `output_tokens` of 41,200. The provider invoice for the same run was 38,900. The delta of 2,300 matched exactly the output tokens of a retried inference span that had been emitted ...",
    "condition_of_validity": "Span-summed token accounting for an agent run is authoritative **only when all of the following hold simultaneously**: 1. **Retry identity is explicit.** Each inference span carries a retry discriminator (e.g., a `gen_ai.request.retry_attempt`-style attribute or a shared logical-call id) such that duplicate logical calls can be collapsed. If the runtime emit...",
    "decision_boundary": "The operational decision is whether to *trust* or *reconcile* the span-derived total: - If conditions 1–5 hold → trust the span sum as the run total; emit it as a derived aggregate metric and close the loop against invoices with a tight tolerance. - If any condition fails → do **not** emit a derived total from spans. Instead, mark the trace as `accounting_in...",
    "operational_effect": "Systems that skip this check exhibit a characteristic failure: token totals drift from invoices in a direction that correlates with error rate and retry volume, and the drift is invisible in per-span dashboards because every individual span is correct. The aggregate is wrong while every input is right. This is the signature of an invalid summation, not a bug..."
  },
  "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": "4c763a58ced59bc7a1cb22c3b6d39ed45ccbfd1c8de14154678a3840de900d12",
    "verified_classes": [
      "TokenAccountingInvariantError",
      "GenAISpan",
      "TraceAccountingConfig"
    ],
    "verified_functions": [
      "_collapse_retries",
      "authoritative_run_tokens"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "TokenAccountingInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "child inference spans may have been dropped by tail sampling; span sum is advisory only",
      "nested agent spans present without declared scoping; aggregate total is structurally ambiguous"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
