{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-reports-genai-token-usage-on-agent-spans-without-matching-tool-call-attributes-a-silent-double-counting-boundary-in-open",
  "title": "What happens when an instance reports GenAI token usage on agent spans without matching tool-call attributes: a silent double-counting boundary in OpenTelemetry GenAI semantic conventions",
  "date_of_record": "2026 November 8",
  "scope": "Applies to OpenTelemetry instrumentation of LLM agent runtimes that emit `gen_ai.*` semantic conventions on both `invoke_agent` and `execute_tool` spans, and to any downstream cost/usage aggregator that sums `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` across a trace. Does not apply to single-shot chat completions without tool loops, nor to spans that only carry `gen_ai.usage.*` on the parent `invoke_agent` span with no child tool spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-on-agent-spans-without-matching-tool-call-attributes-a-silent-double-counting-boundary-in-open.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-on-agent-spans-without-matching-tool-call-attributes-a-silent-double-counting-boundary-in-open.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-reports-genai-token-usage-on-agent-spans-without-matching-tool-call-attributes-a-silent-double-counting-boundary-in-open.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1922,
    "python_slice_tokens": 341,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage as an attribute of the model invocation that produced it. In an agent runtime, a single logical \"agent turn\" is a loop: the model is invoked, it emits tool calls, the runtime executes them, the results are fed back, and the model is invoked again. The convention-compliant way to represent this is one `invoke_a...",
    "what_was_observed": "In a multi-step agent deployment (planner → retrieval tool → synthesis → code-execution tool → final answer), instrumentation was added at two layers by two teams: - The **runtime layer** wrapped the entire agent loop in one `invoke_agent` span and, at loop exit, set `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` to the *sum* of all model calls in the loop. This was done because the runtime had the tota...",
    "condition_of_validity": "The double-counting failure is *latent* (no error, no warning) under all of the following: 1. The parent agent span carries `gen_ai.usage.*` **and** at least one descendant span also carries `gen_ai.usage.*`. 2. The consumer aggregates usage with a flat `sum()` over spans in the trace, rather than selecting a single span per logical invocation (e.g., deepest...",
    "decision_boundary": "Choose the emission strategy by asking: *who owns the loop?* - If the **agent runtime owns the loop** (it decides when to re-invoke the model), the runtime should emit one `invoke_agent` span per loop *iteration*, not per logical agent invocation, and must **not** set cumulative usage on any wrapping span. If a wrapping span is required for trace structure, ...",
    "operational_effect": "The practical consequence is that **trace-derived token accounting is only trustworthy if the producer enforces the \"usage on leaves only\" invariant, and no OpenTelemetry validator enforces it.** A conformant-looking trace can be off by an integer multiple equal to the agent loop depth. The multiplier is not constant across traces, so aggregate error rates l..."
  },
  "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": "9eb4a5fb858ecfab40e7cb5af5cd6fb85366d007a0ba1d8fb74c0c9a50e3f787",
    "verified_classes": [
      "GenAISemconvViolation",
      "SpanRecord"
    ],
    "verified_functions": [
      "_descendants",
      "validate_usage_attribution",
      "validate_tool_call_attribution",
      "validate_trace",
      "has_usage"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenAISemconvViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
