{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-retried-and-why-does-the-naive-span-per-attempt-convent",
  "title": "Where must an instance reconcile OpenTelemetry GenAI token accounting when a tool-call span is retried, and why does the naive span-per-attempt convention double-count?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans (`gen_ai.*` attributes) and performs in-span retries of `execute_tool` operations. Does not apply to runtimes that emit exactly one span per logical tool invocation and absorb retries into a single attempt record, nor to pure LLM completion spans without tool children.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-retried-and-why-does-the-naive-span-per-attempt-convent.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-retried-and-why-does-the-naive-span-per-attempt-convent.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-retried-and-why-does-the-naive-span-per-attempt-convent.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1757,
    "python_slice_tokens": 286,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as the unit of *observed work*, and token usage attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) as *cumulative cost attributable to that span*. These two roles are not the same thing, and the conventions do not force them to coincide. A tool-call span that is retried because the tool returned...",
    "what_was_observed": "A ReAct-style agent executing a `search_corpus` tool against a flaky vector backend. The tool wrapper was configured with three retries and instrumented as follows (pseudocode of the actual emitter): - On entry, open span `execute_tool search_corpus` with `gen_ai.operation.name=\"execute_tool\"`, `gen_ai.tool.name=\"search_corpus\"`. - On each attempt, open a child span `execute_tool.attempt` with `gen_ai.tool.call.id=<u...",
    "condition_of_validity": "The double-count only occurs when all of the following hold: 1. The tool-call is retried *within* a single logical invocation (not promoted to a new top-level agent step). 2. Each attempt is instrumented as a child span carrying `gen_ai.usage.*`. 3. The parent span also carries `gen_ai.usage.*` equal to the aggregate. 4. Some consumer sums usage across the s...",
    "decision_boundary": "The decision boundary is: **does the trace need to answer \"what did this logical operation cost?\" at the span level, or only at the trace level?** - If only at the trace level, emit leaf spans only. Let the aggregator sum leaves. No parent usage attributes. This is the default and the safe choice. - If at the span level (e.g., per-operation cost dashboards),...",
    "operational_effect": "The observable effect is a **cost divergence between trace-derived accounting and provider-side billing**, typically a factor of `1 + retries_observed` on retried tools. Because retries cluster on flaky tools, the divergence is not uniform — it is concentrated on exactly the tools an SRE is most likely to be investigating, which makes the trace look *most wr..."
  },
  "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": "a18e2eadb1d8ba2488d81bc5b0052a4871ff20d07da5a33f6aa212ef9c5f6f96",
    "verified_classes": [
      "GenAiUsageAttributionError",
      "Span"
    ],
    "verified_functions": [
      "assert_usage_attribution",
      "close_tool_span",
      "carries_usage"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAiUsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
