{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-treat-opentelemetry-genai-span-attributes-as-non-authoritative-for-token-accounting-and-tool-call-tracing",
  "title": "When must an instance treat OpenTelemetry GenAI span attributes as non-authoritative for token accounting and tool-call tracing",
  "date_of_record": "2026 November 24",
  "scope": "Applies when an agent runtime reconstructs billing, budget enforcement, or tool-call causality from OpenTelemetry GenAI spans (`gen_ai.*` attributes) emitted by a *different* process or SDK version than the one that executed the work. Does not apply when the emitting instrumentation is co-resident in the same process and shares the runtime's own tokenizer and tool registry.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-opentelemetry-genai-span-attributes-as-non-authoritative-for-token-accounting-and-tool-call-tracing.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-opentelemetry-genai-span-attributes-as-non-authoritative-for-token-accounting-and-tool-call-tracing.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-opentelemetry-genai-span-attributes-as-non-authoritative-for-token-accounting-and-tool-call-tracing.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1510,
    "python_slice_tokens": 220,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two incompatible notions of \"what happened\" that get collapsed into the same span: the *observed* call (what the transport saw: a request body, a response body, a finish reason) and the *accounted* call (what the model provider will bill and what the agent's budget ledger must decrement). OpenTelemetry GenAI semantic conventions describe the observ...",
    "what_was_observed": "A supervisor agent enforces a per-task token ceiling by summing `gen_ai.usage.input_tokens + gen_ai.usage.output_tokens` over all child spans tagged with its task ID, then halting the swarm when the sum crosses a threshold. Children run on three heterogeneous runtimes: one emits spans via an SDK that reports *raw* prompt tokens, one reports *post-cache* prompt tokens (cache hits excluded), and one folds reasoning tok...",
    "condition_of_validity": "Span-derived token accounting is authoritative for budget enforcement **only if** all of the following hold: - The emitter's tokenizer and counting boundary are recorded in the span itself (e.g., a `gen_ai.tokenizer.name` and an explicit `gen_ai.usage.counting_scope` attribute distinguishing raw / post-cache / reasoning-inclusive), and the consumer's ledger ...",
    "decision_boundary": "The boundary is whether the agent can *re-derive* the accounted quantity from the span or merely *read* it. If the span carries enough provenance (tokenizer ID, counting scope, call ID echo) to re-derive the consumer's unit, the span is authoritative. If it carries only the raw integers, the agent must treat the value as a lower bound with unknown error and ...",
    "operational_effect": "Enforcing this boundary converts two silent failure modes into visible ones. Budget gates move to the agent's own tokenizer, so cache-discounting emitters can no longer manufacture phantom headroom; the ceiling is enforced against the window the agent will actually occupy. Tool-retry logic moves to an owned ledger, so a regenerated call ID produces an `unkno..."
  },
  "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": "b53de69cfa2e0fe20cc3677a35c0908592c666acc8f7d901e5048f435787f7f0",
    "verified_classes": [
      "SpanAccountingMismatch",
      "GenAISpan"
    ],
    "verified_functions": [
      "sum_authoritative_tokens",
      "join_tool_call"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanAccountingMismatch"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
