{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-opentelemetry-genai-spans-as-authoritative-for-token-accounting-across-a-multi-step-agent-trajectory",
  "title": "Under what conditions must an instance treat OpenTelemetry GenAI spans as authoritative for token accounting across a multi-step agent trajectory",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents whose per-step token usage is derived from OpenTelemetry GenAI spans (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, tool-call child spans) rather than from the provider's billing API. Does not apply to single-turn, single-span inference calls with no tool fan-out, where the span is trivially complete.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-spans-as-authoritative-for-token-accounting-across-a-multi-step-agent-trajectory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-spans-as-authoritative-for-token-accounting-across-a-multi-step-agent-trajectory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-spans-as-authoritative-for-token-accounting-across-a-multi-step-agent-trajectory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1524,
    "python_slice_tokens": 274,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A GenAI span is a *telemetry artifact* emitted by an instrumented SDK; the token count is a *billing fact* held by the provider. The semantic conventions make spans look authoritative—`gen_ai.usage.input_tokens` is a clean integer attribute—but a span is only emitted when the instrumented code path completes or is explicitly flushed. The failure mode is not ...",
    "what_was_observed": "A three-step agent trajectory (plan → tool-call → synthesize) with one retry on step 2. Per-step span inspection: - Step 1 span: `input_tokens=1840, output_tokens=210`, status OK. - Step 2, attempt A: span emitted with `status=ERROR`, `input_tokens=1840, output_tokens=0`. The provider *did* bill input tokens for the failed attempt (the prompt was sent, the stream was cut mid-completion). - Step 2, attempt B: span `in...",
    "condition_of_validity": "Span-derived token accounting is authoritative for a trajectory **only if all three hold**: 1. **Terminal-span uniqueness per invocation.** The SDK emits exactly one span per provider call, including calls that error, time out, or are cancelled by the agent. Verify by comparing span count for a trace against the provider's request-log count for that trace ID...",
    "decision_boundary": "The agent must switch from span-authoritative to invoice-authoritative accounting—or refuse to emit a cost/token figure—under the following trigger, evaluated per trajectory: - **Ambiguity trigger:** `count(spans with status in {ERROR, CANCELLED} and usage attributes absent) > 0` for the trace. This is the decisive condition. A single such span makes the sum...",
    "operational_effect": "Concretely, an agent enforcing this boundary will: - Emit a per-trajectory accounting record tagged `authoritative: false` with `lower_bound_tokens` when the ambiguity trigger fires, rather than a bare integer that downstream budget enforcement will treat as exact. - Halt budget-driven execution (e.g., a hard token cap) on the *invoice* figure when available..."
  },
  "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": "4d2230fb310e850da57962b24bc69d3f2bf4dfdee5c47ac5f991dc5e23a5904c",
    "verified_classes": [
      "UnattributedTerminalSpanError",
      "GenAISpan"
    ],
    "verified_functions": [
      "assert_span_accounting_authoritative",
      "reconcile_against_invoice"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UnattributedTerminalSpanError"
    ],
    "sample_fail_closed_invariants": [
      "no invoice figure to reconcile against; cannot certify authority"
    ],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
