{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-reports-gen-ai-usage-input-tokens-on-a-tool-call-child-span-but-not-on-the-parent-agent-span",
  "title": "What happens when an instance reports `gen_ai.usage.input_tokens` on a tool-call child span but not on the parent agent span",
  "date_of_record": "2026 November 14",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (v1.27–v1.31) for agent invocation spans that emit `gen_ai.operation.name = \"invoke_agent\"` or `\"create_agent\"` and which parent one or more `execute_tool` child spans. Does not apply to pure LLM inference spans (`gen_ai.operation.name = \"chat\"`), nor to providers that aggregate usage exclusively at the root span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-gen-ai-usage-input-tokens-on-a-tool-call-child-span-but-not-on-the-parent-agent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-gen-ai-usage-input-tokens-on-a-tool-call-child-span-but-not-on-the-parent-agent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-gen-ai-usage-input-tokens-on-a-tool-call-child-span-but-not-on-the-parent-agent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1584,
    "python_slice_tokens": 380,
    "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 *per-operation* counters, not *per-tree* counters. There is no normative rule that says a parent agent span's usage must equal the sum of its children. However, most backends (Grafana Tempo's span metrics, Datadog's LLM Observability, Langfuse's cost rollup)...",
    "what_was_observed": "In a production trace captured from a LangGraph-style agent with three tools (a vector-search tool, a SQL tool, and a web-fetch tool), the following span structure was emitted: - `invoke_agent` (root): `gen_ai.usage.input_tokens = 18420`, `gen_ai.usage.output_tokens = 911` - `chat` (child, planning step): `gen_ai.usage.input_tokens = 1204`, `gen_ai.usage.output_tokens = 88` - `execute_tool` (child, `vector_search`): ...",
    "condition_of_validity": "The double-counting only occurs when **all three** of the following hold simultaneously: 1. The parent agent span emits `gen_ai.usage.input_tokens` with a value that includes child LLM work (i.e., the agent framework accumulates usage across its internal loop before closing the root span). 2. At least one child `execute_tool` span also emits `gen_ai.usage.in...",
    "decision_boundary": "When instrumenting or consuming agent spans, choose exactly one model and enforce it at the SDK boundary, not the backend: - **Emit-on-root-only** if your agent framework can accumulate usage before span close. Suppress `gen_ai.usage.*` on all `execute_tool` and `chat` child spans. This is the model most backends expect and is the safest default. - **Emit-on...",
    "operational_effect": "The observable symptom is a cost-report inflation factor that is stable per agent configuration but varies across configurations — because it depends on tool fan-out and which tools internally call LLMs. Alerting on absolute token counts will fire spuriously; alerting on the *ratio* of reported tokens to billed tokens (where billing data is available) is the..."
  },
  "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": "10d217946b58981c4882b8c7b1c4e2522fd86125927e447215f862228d52bdac",
    "verified_classes": [
      "UsageModelViolation",
      "SpanUsage"
    ],
    "verified_functions": [
      "validate_usage_model",
      "build_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UsageModelViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
