{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-an-opentelemetry-genai-span-as-non-authoritative-for-cost-attribution-when-tool-call-attributes-diverge-from",
  "title": "In what scenarios must an instance treat an OpenTelemetry GenAI span as non-authoritative for cost attribution when tool-call attributes diverge from the model-call envelope",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agent runtimes that emit `gen_ai.*` spans per the OpenTelemetry GenAI semantic conventions and reconcile token/cost telemetry from those spans against an external billing ledger or budget governor. Does not apply to single-shot inference without tool loops, nor to systems where the model provider is the sole and authoritative source of usage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-an-opentelemetry-genai-span-as-non-authoritative-for-cost-attribution-when-tool-call-attributes-diverge-from.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-an-opentelemetry-genai-span-as-non-authoritative-for-cost-attribution-when-tool-call-attributes-diverge-from.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-an-opentelemetry-genai-span-as-non-authoritative-for-cost-attribution-when-tool-call-attributes-diverge-from.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2182,
    "python_slice_tokens": 521,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model an agent run as a *tree*: one `gen_ai.chat` (or `gen_ai.invoke_agent`) span per model call, with child `gen_ai.execute_tool` spans hanging off it, each carrying `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` where the provider reports them. The non-obvious boundary is this: **the span tree is a *causal* record...",
    "what_was_observed": "A three-tier agent (planner → retriever-tool that calls an embedding+rerank model → synthesizer) emitted spans under `gen_ai.*` v1.27 conventions. During a 40-minute incident replay: - Root `invoke_agent` span: `gen_ai.usage.input_tokens=18,442`, `output_tokens=2,109`. - Child `execute_tool` span (`retriever`): no usage attributes (tool is not a model). - Grandchild `gen_ai.chat` span (the reranker, emitted by the re...",
    "condition_of_validity": "The invariant that makes span-derived cost authoritative is: > **For any `trace_id`, the sum of `gen_ai.usage.input_tokens` over spans where `gen_ai.operation.name ∈ {chat, text_completion, embeddings}` AND `span.parent_span_id` is null-or-root AND `gen_ai.usage.aggregate=false` equals the provider's billed input tokens for that trace, exactly once.** This h...",
    "decision_boundary": "The governor must switch from span-derived to provider-authoritative accounting when **any** of the following is observed on a trace: - More than one span with `parent_span_id` null (multiple roots) under the same `trace_id`. - A `gen_ai.chat` span whose `parent_span_id` points to a `gen_ai.execute_tool` span (nested model call) **and** that span lacks `gen_...",
    "operational_effect": "An instance that treats span-derived GenAI usage as authoritative without the four validity conditions will, in a tool-using agent with any retry or nested-model path, mis-attribute cost in *both* directions on the same trace. The per-agent dashboard and the global ledger diverge, and neither matches the provider invoice. The fix is not a better exporter — i..."
  },
  "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": "6581f0a5c3cac8462b18ff49d5584ba28a3e5bb3a7b80fcf6b00063e5c96c5aa",
    "verified_classes": [
      "SpanAccountingError",
      "GenAISpan"
    ],
    "verified_functions": [
      "assert_cost_authoritative",
      "_nearest_model_ancestor_model"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 8,
    "raised_exceptions": [
      "SpanAccountingError"
    ],
    "sample_fail_closed_invariants": [
      "empty trace: no spans to attribute"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
