{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-emit-a-genai-agent-span-double-counted-tokens-and-orphaned-tool-call-attributes-at-the-span-boundary",
  "title": "When must an instance Refuse to Emit a GenAI Agent Span: Double-Counted Tokens and Orphaned Tool-Call Attributes at the Span Boundary",
  "date_of_record": "2026 November 11",
  "scope": "Applies to instrumentation that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*` attributes) for agent invocations, tool calls, and LLM operations, where token usage is aggregated across nested spans or where tool-call identifiers are resolved across span boundaries. Does not apply to single-span, single-model-call instrumentation with no nested agent or tool hierarchy, nor to metrics-only emitters that do not produce spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-double-counted-tokens-and-orphaned-tool-call-attributes-at-the-span-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-double-counted-tokens-and-orphaned-tool-call-attributes-at-the-span-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-emit-a-genai-agent-span-double-counted-tokens-and-orphaned-tool-call-attributes-at-the-span-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1478,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *per-operation* attributes: `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` are defined as the token counts for the model operation that the span represents. They are not defined as deltas, and they are not defined as child-inclusive. The non-obvious boundary is this: an *agent span* (a span with `gen_ai.o...",
    "what_was_observed": "In a multi-agent orchestration deployment, a parent agent span emitted aggregate token counts equal to the sum of its three child LLM spans. Trace-derived billing showed a 4.1× overcount on input tokens: once for each child, once for the parent, plus the root trace span which also carried aggregates. The overcount was invisible in per-span inspection because each span's attributes were individually \"correct\" in the s...",
    "condition_of_validity": "The refusal rule holds whenever all of the following are true: 1. The span has `gen_ai.operation.name` denoting an agent or orchestration operation (not a single model inference). 2. The span has one or more descendant spans carrying `gen_ai.usage.input_tokens` or `gen_ai.usage.output_tokens`. 3. The emitting backend or downstream consumer is known to aggreg...",
    "decision_boundary": "The instance must choose between two mutually exclusive behaviors at the point of span finalization: - **Emit aggregate usage on the agent span** — valid only when no descendant emits usage, or when the consumer is explicitly configured for leaf-only aggregation. - **Suppress usage on the agent span** — required when descendants emit usage and the consumer a...",
    "operational_effect": "Instrumentation that violates these boundaries produces traces that pass every schema validator and fail every aggregation. The observable symptoms are: token dashboards inflated by a factor equal to nesting depth; tool-call analytics silently empty; cost attribution split across spans that cannot be reconciled; and alerting on token budgets that fires at th..."
  },
  "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": "da32a7a1104970743aea1ba3daa98f985d7c4fdec8652cc45dfe252aba1282c4",
    "verified_classes": [
      "GenAISpanInvariantError",
      "GenAISpan"
    ],
    "verified_functions": [
      "validate_before_export"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAISpanInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
