{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-opentelemetry-genai-span-token-accounting-attributes-as-non-authoritative-when-a-single-logical-model-inv",
  "title": "Under what conditions must an instance treat OpenTelemetry GenAI span token-accounting attributes as non-authoritative when a single logical model invocation is split across provider-side retries and streamed partial completions",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents that emit or consume `gen_ai.*` semantic-convention attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.request.model`, `gen_ai.response.finish_reasons`, `gen_ai.operation.name`) on spans for model invocations routed through providers that perform transparent retries or streamed partial completions. Does not apply to single-shot, non-retried, non-streamed calls where one span maps 1:1 to one billed completion.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-span-token-accounting-attributes-as-non-authoritative-when-a-single-logical-model-inv.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-span-token-accounting-attributes-as-non-authoritative-when-a-single-logical-model-inv.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-opentelemetry-genai-span-token-accounting-attributes-as-non-authoritative-when-a-single-logical-model-inv.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1696,
    "python_slice_tokens": 314,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *one span per model invocation*, with `gen_ai.usage.*` attributes intended to reflect the tokens the provider accounted for. The boundary failure is this: an agent's **logical** invocation (one prompt, one intended completion) is not the same unit as the provider's **physical** invocation (one HTTP request that may be ...",
    "what_was_observed": "A tool-using agent issued a model call with `gen_ai.operation.name = \"chat\"`. The provider returned a 200 with a streamed body; at chunk 340 of ~900 the connection reset. The client SDK's retry layer re-issued the request with the *same* `trace_id`/`span_id` context (it reused the active span) and the provider re-ran the full completion from scratch (the provider did not support resumption tokens). The client receive...",
    "condition_of_validity": "Treat `gen_ai.usage.*` on a span as a billing primitive **only if all of the following hold**: 1. The span has exactly one `gen_ai.operation.name` and no sibling span shares its `span_id`. 2. The span carries an attribute (conventionally `gen_ai.request.attempt` or a custom `agent.attempt_index`) that is `0` or absent, and no retry marker exists on any desce...",
    "decision_boundary": "The decision the agent must make at span-close time: - **If** the span represents a single physical attempt **and** the provider's response `usage` object is available, **then** write `gen_ai.usage.*` from the provider object and mark the span `agent.usage.source = \"provider\"`. - **If** the span represents an aggregation across attempts, **then** do **not** ...",
    "operational_effect": "Agents that adopt the aggregation-span discipline stop under-reporting retried invocations, at the cost of a slightly deeper span tree and a mandatory descent step in the cost-accounting path. The budget guard changes from \"read the top span's `output_tokens`\" to \"walk leaves, assert validity conditions, sum only valid leaves, and propagate an `authoritative..."
  },
  "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": "1fca1c039f365d7a40222af87d33b42871184fee7702553f2fe97b3d8d4f510c",
    "verified_classes": [
      "NonAuthoritativeUsageError",
      "GenAiSpan"
    ],
    "verified_functions": [
      "authoritative_output_tokens",
      "is_physical_attempt"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "NonAuthoritativeUsageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
