{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-opentelemetry-genai-span-attribution-from-silently-mispricing-agent-tool-call-trees-under-concurrent-retries",
  "title": "Which invariants prevent OpenTelemetry GenAI span attribution from silently mispricing agent tool-call trees under concurrent retries",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic conventions (`gen_ai.*`) for reasoning steps, tool calls, and token/cost metrics, where tool calls may be retried concurrently or replayed by an outer supervisor. Does not apply to single-shot, single-threaded inference calls with no retry or fan-out topology.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attribution-from-silently-mispricing-agent-tool-call-trees-under-concurrent-retries.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attribution-from-silently-mispricing-agent-tool-call-trees-under-concurrent-retries.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-attribution-from-silently-mispricing-agent-tool-call-trees-under-concurrent-retries.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1517,
    "python_slice_tokens": 252,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing spans\" or \"wrong token counts.\" It is **double-attributed cost with single-attributed latency**: a retried tool call produces two child spans that both carry the *same* `gen_ai.usage.input_tokens` / `output_tokens` and the same `gen_ai.usage.cost` attributes, but only one of them is linked by `trace_id`+`span_id` to the parent rea...",
    "what_was_observed": "A supervisor agent fans out three tool calls (`search`, `fetch`, `summarize`) to a worker pool. Each tool call is an LLM-backed sub-agent that emits a `gen_ai` span. The `fetch` tool intermittently returns a timeout; the runtime's retry policy re-invokes it. Trace replay showed: - The `fetch` operation emitted 2 spans: `fetch.attempt=0` (status `error`, `gen_ai.usage.input_tokens=1840`, `output_tokens=210`, `cost=0.0...",
    "condition_of_validity": "The invariant holds only when all of the following are true: 1. Every physically-billed invocation emits a span with `gen_ai.operation.name` set (e.g., `chat`, `execute_tool`) and a **stable** `gen_ai.usage.*` set. If the runtime batches token accounting at the parent (aggregating child usage into the parent span and emitting nothing on children), the double...",
    "decision_boundary": "The boundary is: **does the runtime retry inside the span, or as sibling spans?** - *Retry inside the span* (loop within one `gen_ai` span, incrementing an attempt attribute): usage is summed correctly by construction, but the span's latency now hides retry amplification and the status attribute must reflect the *final* attempt, not the first. This is safe f...",
    "operational_effect": "The downstream effect is a **cost/latency divergence that is invisible in any single trace but systematic across a fleet**: high-retry operations (flaky tools, rate-limited endpoints) get overcounted in cost and undercounted in latency, so the agent's *slowest* paths look *cheapest*. Capacity planning under-provisions the retry-heavy tools, and cost attribut..."
  },
  "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": "4430a81cb0a0c62eed27b49725c4db6042687a841c5fe5c4913537e753c0a98b",
    "verified_classes": [
      "GenAiAttributionError"
    ],
    "verified_functions": [
      "validate_usage_attribution"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAiAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
