{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-close-a-genai-span-when-token-usage-attributes-disagree-with-the-provider-s-billed-counts-across-a-tool-c",
  "title": "In what scenarios must an instance refuse to close a GenAI span when token-usage attributes disagree with the provider's billed counts across a tool-call fan-out",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.tool.name`, etc.) and reconcile those counters against provider billing or a downstream cost ledger. Does not apply to systems that emit only trace context with no token accounting, nor to single-shot, tool-free completions where one span maps 1:1 to one billed request.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-span-when-token-usage-attributes-disagree-with-the-provider-s-billed-counts-across-a-tool-c.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-span-when-token-usage-attributes-disagree-with-the-provider-s-billed-counts-across-a-tool-c.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-span-when-token-usage-attributes-disagree-with-the-provider-s-billed-counts-across-a-tool-c.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2178,
    "python_slice_tokens": 554,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model *a span per model invocation*. The provider bills *a request per HTTP call*. These are the same object only when the invocation is a leaf. The moment an agent fans out — one reasoning step that dispatches N parallel tool calls, each of which may itself re-enter the model — the convention's per-span `gen_ai.usage.*` attrib...",
    "what_was_observed": "A planner agent executed a task with `gen_ai.operation.name = \"chat\"` on a root span, and within it issued four parallel `execute_tool` child spans (`gen_ai.tool.name` in `{search, fetch, sql_query, summarize}`). Three of the four tools returned small payloads; the `fetch` tool returned a 90 KB document that the agent then re-fed into the model in a follow-up chat span. The observed sequence: 1. Root chat span opened...",
    "condition_of_validity": "The per-span usage attribute is valid **iff** the span corresponds to exactly one provider request whose response carried a `usage` object, and no descendant span represents an additional billed request. This holds for leaf chat spans and for tool spans that invoke no model. It fails — silently, without any schema violation — whenever: - A parent chat span's...",
    "decision_boundary": "The instance must decide, at span-close time, whether it is authorized to finalize a usage attribute it cannot verify. The boundary: - **Leaf chat span, usage object received:** finalize. The attribute is a direct transcription of provider truth. - **Leaf chat span, usage object missing (stream truncated, error mid-stream):** do **not** finalize with a token...",
    "operational_effect": "An instance that enforces this boundary converts a silent, month-latency billing drift into a synchronous, per-trace signal. The cost is a small amount of span-close latency (one reconciliation lookup per parent span) and the obligation to carry provider request IDs through the trace as a link attribute. The benefit is that budget governors, anomaly detector..."
  },
  "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": "d243fe76026d46062038fd081d0b75d53673ae95c87f1a80736ed4622309cff0",
    "verified_classes": [
      "UnverifiedUsageError",
      "Span"
    ],
    "verified_functions": [
      "close_span",
      "chat_descendant_usage"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "UnverifiedUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
