{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-token-accounting-divergence-between-agent-spans-and-their-tool-call-children-in-opentelemetry-genai-traces",
  "title": "What structural signals indicate token-accounting divergence between agent spans and their tool-call children in OpenTelemetry GenAI traces",
  "date_of_record": "2026 November 7",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (`gen_ai.*`) as emitted for agent and tool-call spans, specifically the propagation of token usage attributes across parent/child span relationships in multi-agent and tool-invoking agent systems. Does not apply to single-shot LLM inference spans with no child tool-call spans, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-divergence-between-agent-spans-and-their-tool-call-children-in-opentelemetry-genai-traces.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-divergence-between-agent-spans-and-their-tool-call-children-in-opentelemetry-genai-traces.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-token-accounting-divergence-between-agent-spans-and-their-tool-call-children-in-opentelemetry-genai-traces.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1568,
    "python_slice_tokens": 278,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define token accounting attributes — `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` — as properties of a *model invocation*, not of an *agent turn*. An agent span (`gen_ai.operation.name = \"invoke_agent\"` or equivalent) is a container; the tokens it \"consumed\" are the sum of the model invocations it caused. The no...",
    "what_was_observed": "In a multi-agent trace where a planner agent invokes a search tool, the following span tree was emitted: - `invoke_agent` (planner), `gen_ai.usage.input_tokens = 1840`, `output_tokens = 212` - └─ `execute_tool` (search), `gen_ai.usage.input_tokens = 1840`, `output_tokens = 212` (copied) - └─ `chat` (model call that decided to call the tool), `gen_ai.usage.input_tokens = 1840`, `output_tokens = 212` The three spans ar...",
    "condition_of_validity": "The divergence diagnosis holds only when all of the following are true: 1. The instrumentation emits `gen_ai.operation.name` on every span, distinguishing `chat` (model invocation) from `execute_tool` from `invoke_agent`. Without this discriminator, usage attributes cannot be attributed to a span *kind*. 2. Usage attributes are reported per-span, not only on...",
    "decision_boundary": "The operational decision is whether to sum token usage over all spans or to sum only over `chat` spans (and, when absent, over agent spans as a fallback). The boundary condition: - **Sum over `chat` spans only** when `gen_ai.operation.name` is reliably present and every model invocation is instrumented. This is correct and avoids double-count. - **Sum over `...",
    "operational_effect": "Teams that aggregate by naive span-sum over-report token spend by a factor equal to the average number of tool calls per agent turn (commonly 1.5–3× in retrieval-heavy agents), and this error is *invisible* in per-trace dashboards because it scales uniformly. The failure surfaces only when reconciling against provider billing, at which point the mismatch is ..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "88f278247813479aa15cf2d0f8277e7e32d88e4bd196fa549f60e679995b4405",
    "verified_classes": [
      "TokenAccountingAmbiguity",
      "Span"
    ],
    "verified_functions": [
      "reconcile_tokens"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenAccountingAmbiguity"
    ],
    "sample_fail_closed_invariants": [
      "no chat spans present; cannot distinguish copied tool usage from genuine un-instrumented model calls"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
