{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-single-agent-span-fans-out-into-retried-tool-calls-that-the-exporter-sees",
  "title": "How should an instance reconcile OpenTelemetry GenAI token accounting when a single agent span fans out into retried tool calls that the exporter sees as siblings",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*`) where a logical LLM invocation is retried or where a tool-call span is re-emitted after a transient failure, causing the exporter to record sibling spans. Does not apply to single-shot, non-retried invocations or to backends that deduplicate spans by `span_id` before aggregation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-single-agent-span-fans-out-into-retried-tool-calls-that-the-exporter-sees.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-single-agent-span-fans-out-into-retried-tool-calls-that-the-exporter-sees.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-single-agent-span-fans-out-into-retried-tool-calls-that-the-exporter-sees.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1907,
    "python_slice_tokens": 469,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes of a span representing *one* model invocation. They are additive counters, not gauges. The conventions are silent on what a span means when the same logical invocation is attempted N times. Two interpretations are both defensible and mutually excl...",
    "what_was_observed": "A planner agent executes a `gen_ai.tool.call` span wrapping a `gen_ai.chat` child. The tool (a retrieval call) returns a 503 on the first attempt. The framework's retry wrapper re-invokes the model to reformulate the query. Trace emitted: The parent span `A` carries an aggregate that was computed *before* the retry, because the aggregate attribute was set at span-start by the framework's `with_span` context manager a...",
    "condition_of_validity": "The additive interpretation (span-as-attempt) is valid only when all of the following hold: - Every retry emits a span with a **distinct** `span_id` and a shared `gen_ai.request.model` + a correlation attribute (the conventions reserve no standard retry attribute; `gen_ai.request.id` is not defined for retries, so implementations typically overload `gen_ai.r...",
    "decision_boundary": "An instance must choose its accounting contract *before* the first span is emitted, and encode it in a single attribute that the exporter's aggregation pipeline can key on. The boundary: - If `gen_ai.usage.*` appears on more than one span in an ancestor chain (parent + child both carry it), the instance must treat the parent as authoritative and drop child u...",
    "operational_effect": "When the invariant holds, cost dashboards are exact and budget guardrails fire only on real exhaustion. When it is violated, the two failure directions are asymmetric and both bad: - **Over-count** (observed): guardrail trips early, the agent aborts a task with budget remaining, and the resume path re-runs from a checkpoint that does not include the aborted ..."
  },
  "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": "e2e06b1bfcf9a1f2d5949b560ff2f48a34e2ea8422f7d53e9732b08ed46ab299",
    "verified_classes": [
      "TokenAccountingInvariantError",
      "Span"
    ],
    "verified_functions": [
      "reconcile_usage",
      "assert_budget_guardrail"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TokenAccountingInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
