{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-emit-a-valid-gen-ai-operation-name-span-with-gen-ai-usage-attributes-that-silently-under-bill-a-retried-tool-call-fan-out",
  "title": "Why does an instance emit a valid gen_ai.operation.name span with gen_ai.usage.* attributes that silently under-bill a retried tool-call fan-out?",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI spans per model invocation and per tool execution, where cost/usage is reconstructed downstream by summing `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` on spans bearing `gen_ai.operation.name`. Does not apply to runtimes that meter at the HTTP transport layer or that bill from provider-side invoices independent of span emission.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-valid-gen-ai-operation-name-span-with-gen-ai-usage-attributes-that-silently-under-bill-a-retried-tool-call-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-valid-gen-ai-operation-name-span-with-gen-ai-usage-attributes-that-silently-under-bill-a-retried-tool-call-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-valid-gen-ai-operation-name-span-with-gen-ai-usage-attributes-that-silently-under-bill-a-retried-tool-call-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2147,
    "python_slice_tokens": 487,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *per-span* attributes: a single `chat` span carries `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and a `gen_ai.operation.name` of `chat`, `execute_tool`, `embeddings`, etc. They do **not** define a parent-level rollup attribute, a deduplication key, or a retry ordinal. The distinction that matters operati...",
    "what_was_observed": "An agent executing a `plan → tool-call → observe` loop against a function-calling model. The tool call to `search_index` intermittently returned a 429 from the provider; the runtime's retry wrapper re-issued the *entire* model call (not just the tool), producing a second `chat` span. Each span was individually well-formed: - `gen_ai.operation.name = \"chat\"` - `gen_ai.system = \"openai\"` (or the vendor equivalent) - `g...",
    "condition_of_validity": "The \"sum usage over spans\" rollup is valid only when *all three* hold: 1. **No retried model calls within a logical agent step** — i.e., the runtime either does not retry `chat` calls, or retries at a layer that does not emit a new `chat` span. 2. **Usage attributes are populated only from provider responses**, never from pre-flight estimates, so an error sp...",
    "decision_boundary": "The boundary is not \"should I retry\" — retries are mandatory for reliability. The boundary is **where the usage attribute is written and whether the span is exportable as a cost-bearing span**: - If the runtime writes `gen_ai.usage.*` at span *start* from an estimate, then an error span is a cost span and the aggregator must filter `status.code = OK` *and* t...",
    "operational_effect": "Consequences of getting this wrong, in order of severity: 1. **Silent over-billing of 2–N× on retry-heavy agents.** Rate-limited agents (the ones most likely to retry) are exactly the ones whose cost dashboards inflate. The inflation correlates with provider instability, so it looks like \"costs went up when the provider got flaky\" — which is half-true and mi..."
  },
  "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": "91cf0a0a7586b4335ba24e5efb90b40ae110d134843b298f3e513e7a37768172",
    "verified_classes": [
      "CostRollupInvariantError",
      "GenAiSpan"
    ],
    "verified_functions": [
      "rollup_step_cost",
      "reconcile_against_invoice"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CostRollupInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
