{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-reject-an-opentelemetry-genai-agent-span-whose-tool-call-token-accounting-has-drifted-from-its-par",
  "title": "When must an instance reject an OpenTelemetry GenAI agent span whose tool-call token accounting has drifted from its parent invoke_agent span?",
  "date_of_record": "2026 November 6",
  "scope": "Applies to services emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name` = `invoke_agent`, `execute_tool`, `chat`) where a single logical agent turn fans out into nested tool calls that each carry their own `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`. Does not apply to single-shot chat spans without tool fan-out, nor to spans where token usage is intentionally aggregated only at the root.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-agent-span-whose-tool-call-token-accounting-has-drifted-from-its-par.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-agent-span-whose-tool-call-token-accounting-has-drifted-from-its-par.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-an-opentelemetry-genai-agent-span-whose-tool-call-token-accounting-has-drifted-from-its-par.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1507,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *per-span* measurements of the model call that span represents. They are **not** a rollup. A parent `invoke_agent` span and its child `execute_tool` spans each legitimately report only the tokens consumed by their own model invocation. The non-obvious invaria...",
    "what_was_observed": "In a multi-tool agent (planner → 3 parallel `execute_tool` calls → synthesizer), the emitted trace showed: - Root `invoke_agent` span: `input_tokens=4820`, `output_tokens=610`. - Three child `execute_tool` spans, each with an *internal* `chat` child: the tool spans carried `gen_ai.usage.input_tokens` copied from their nested chat calls (a common exporter bug where the tool wrapper propagates the child's usage upward)...",
    "condition_of_validity": "The additive-leaf invariant holds **only when**: 1. Every span carrying `gen_ai.usage.*` either (a) represents exactly one model invocation (`chat`, or an `invoke_agent` that itself calls the model exactly once), or (b) is the single designated rollup root, and these two roles are never conflated on the same span. 2. `execute_tool` spans that do not invoke a...",
    "decision_boundary": "An instance **must reject** (fail the span, not silently accept) when it detects, at emission or ingestion: - A span with `gen_ai.operation.name=execute_tool` that carries non-zero `gen_ai.usage.input_tokens` **and** has a descendant `chat` span whose `gen_ai.usage.input_tokens` equals it. This is the copy-up signature; accepting it guarantees double-countin...",
    "operational_effect": "Enforcing the boundary at the `execute_tool` copy-up signature converts a silent 2–3× cost inflation into a hard, attributable error at the exporter, where it can be fixed (strip usage attributes from tool wrappers; let the nested `chat` span own them). Downstream, cost attribution becomes trustworthy: per-tool spend is computed only from `chat` leaves, and ..."
  },
  "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": "7fe52ad65480453988868c3d06735a57d7b5e286884b439f0d7b9016d814158d",
    "verified_classes": [
      "GenAISpanAccountingError",
      "Span"
    ],
    "verified_functions": [
      "_usage",
      "validate_agent_trace",
      "descendants"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenAISpanAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
