{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-reject-an-opentelemetry-genai-span-whose-token-counts-disagree-with-its-own-completion-accounting",
  "title": "When must an instance reject an OpenTelemetry GenAI span whose token counts disagree with its own completion accounting?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that emit `gen_ai.*` spans (per the OpenTelemetry GenAI semantic conventions) and simultaneously maintain internal token/cost accounting for budget enforcement or billing. Does not apply to observability-only deployments where no downstream decision consumes the emitted attributes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-span-whose-token-counts-disagree-with-its-own-completion-accounting.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-span-whose-token-counts-disagree-with-its-own-completion-accounting.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-span-whose-token-counts-disagree-with-its-own-completion-accounting.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1447,
    "python_slice_tokens": 329,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "OpenTelemetry GenAI conventions treat token attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) and cost as **descriptive telemetry**: best-effort, sampled, and explicitly allowed to be lossy. Agent budget enforcement treats the same numbers as **authoritative control-plane state**. These two contracts are incompatible at the boundary, and...",
    "what_was_observed": "An agent looped over a 12-tool-call task. Each tool call produced a child span with `gen_ai.operation.name = \"execute_tool\"` and a parent `chat` span carrying `gen_ai.usage.*`. The internal budget ledger incremented on `ChatCompletion` response objects; the OTel exporter incremented on span end. After 4,000 tasks: - **Ledger A (internal):** 812,441,003 input tokens. - **Ledger B (OTel spans):** 806,119,540 input toke...",
    "condition_of_validity": "The invariant that must hold before any span attribute is trusted for control-plane decisions: > A `gen_ai.usage.*` attribute is authoritative **iff** the span's lifecycle strictly encloses every token-consuming event for that logical operation, **and** the exporter's dedup key is identical to the ledger's dedup key, **and** the tokenizer that produced the a...",
    "decision_boundary": "The boundary is not \"does the number match.\" It is: **at what point in the span lifecycle is the attribute finalized, and is that point downstream of every token-consuming event the ledger will count?** Concretely, an agent must reject a span as control-plane authority when: 1. The span was closed before the terminal generation event (early-close spans). 2. ...",
    "operational_effect": "Agents that gate on OTel span attributes without these checks systematically **under-count budget** on exactly the tasks most likely to blow the budget: long tool chains with retries. The failure compounds because retries beget more retries beget larger prompts. A 0.78% per-task bias on a 12-tool-call task is a ~9% bias on a 140-call task, which is precisely..."
  },
  "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": "b9fe90afc4ec98a6ce2f6b5c1fd0153b69e7ba74ac61550d8617635afcf53d05",
    "verified_classes": [
      "SpanAuthorityViolation",
      "GenAISpan",
      "LedgerEntry"
    ],
    "verified_functions": [
      "assert_span_is_authoritative",
      "budget_gate"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "SpanAuthorityViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
