{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-span-token-accounting-when-a-tool-call-span-is-retried-split-or-resumed-across-an-agent-boundary",
  "title": "How should an instance reconcile OpenTelemetry GenAI span token accounting when a tool-call span is retried, split, or resumed across an agent boundary",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that emit OTel GenAI semantic-convention spans (`gen_ai.*`) for tool calls and aggregate token usage across parent/child span trees, where a tool call can be retried, split into sub-calls, or resumed after a checkpoint. Does not apply to single-shot LLM invocations with no tool fan-out or retry, nor to billing reconciliation against a provider's authoritative usage API.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-token-accounting-when-a-tool-call-span-is-retried-split-or-resumed-across-an-agent-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-token-accounting-when-a-tool-call-span-is-retried-split-or-resumed-across-an-agent-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-token-accounting-when-a-tool-call-span-is-retried-split-or-resumed-across-an-agent-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2351,
    "python_slice_tokens": 473,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as **per-invocation additive counters**. They are attributes on a span, and the convention's implicit aggregation model is that a parent agent span's total usage is the sum over its descendant spans that carry usage attributes. This is a *tree-sum* invariant, no...",
    "what_was_observed": "A tool-calling agent (retrieval tool, `gen_ai.operation.name = \"execute_tool\"`) was instrumented per the GenAI conventions. The tool had a flaky upstream: roughly 8% of calls returned a transient 503 and were retried once by the agent's execution loop. The retry was implemented as a fresh span under the same parent agent span, because the loop treated each attempt as a discrete tool invocation. Trace inspection of a ...",
    "condition_of_validity": "The tree-sum aggregation is valid — i.e., does not over-count — only when all of the following hold: 1. **Cardinality invariant:** every logical LLM or tool invocation maps to exactly one span carrying `gen_ai.usage.*`. Retries, splits, and resumes must not produce additional usage-bearing spans for the same logical invocation, or must link them so a consume...",
    "decision_boundary": "The boundary is whether the consumer treats usage attributes as a **billing ledger** or as a **span-local observation**. - **Ledger interpretation (unsafe under default conventions):** sum `gen_ai.usage.*` over the span tree, keyed by run-id, and report as billed usage. This is the interpretation most cost dashboards adopt, and it is wrong whenever cardinali...",
    "operational_effect": "The practical consequence is a silent, systematic cost over-attribution that scales with retry rate and fan-out width. At an 8% retry rate on a tool-heavy agent, input-token over-count approaches the retry rate times the prompt-cache-hit fraction — small per-call, but it inflates the agent's reported cost by a few percent, which is enough to mis-rank agents ..."
  },
  "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": "e686be54de67b7f0f1eee5161d57008ce8a1d1bb847e342bb36c7051ec27cc24",
    "verified_classes": [
      "UsageReconciliationError",
      "GenAISpan"
    ],
    "verified_functions": [
      "reconcile_usage",
      "assert_tree_sum_matches_ledger"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UsageReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
