{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-abort-a-genai-span-tree-when-token-usage-attributes-disagree-across-nested-agent-and-tool-spans",
  "title": "Under what conditions must an instance abort a GenAI span tree when token-usage attributes disagree across nested agent and tool spans",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where an orchestrator span, delegated sub-agent spans, and tool-execution spans each report `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` and derived cost. Does not cover single-span synchronous inference calls where only one span attributes usage, nor provider-side billing reconciliation outside the trace.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abort-a-genai-span-tree-when-token-usage-attributes-disagree-across-nested-agent-and-tool-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abort-a-genai-span-tree-when-token-usage-attributes-disagree-across-nested-agent-and-tool-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-abort-a-genai-span-tree-when-token-usage-attributes-disagree-across-nested-agent-and-tool-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1375,
    "python_slice_tokens": 252,
    "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 *span-local* attributes: each span that performs a model invocation reports what that invocation consumed. There is no normative rule that a parent agent span's usage equals the sum of its children, because a parent agent may itself invoke a model (planning, ...",
    "what_was_observed": "An orchestrator agent (`gen_ai.operation.name=invoke_agent`) spawned two sub-agents via a handoff tool. Each sub-agent span carried `gen_ai.usage.input_tokens` reflecting its full context — which included the orchestrator's conversation history replayed into the child. The orchestrator span *also* reported `gen_ai.usage.input_tokens` for its own planning turns, computed over the same shared history. Downstream cost a...",
    "condition_of_validity": "The tree-sum cost is trustworthy **iff** every token-consuming span's context is disjoint from every other span's context, or the emitter explicitly marks inherited context so the aggregator can subtract it. Concretely, the invariant is: > For any span tree rooted at an `invoke_agent` span, `Σ(gen_ai.usage.input_tokens over all descendant spans) ≤ gen_ai.usa...",
    "decision_boundary": "An instance must **abort tree-sum attribution and fall back to root-authoritative usage** when, at trace close, the summed descendant `gen_ai.usage.input_tokens` exceeds the root span's provider-reported `input_tokens` by more than a tolerance (recommend 5% to absorb tokenizer edge cases and cached-token rounding). Below tolerance, tree-sum is a legitimate b...",
    "operational_effect": "When the boundary trips, the agent must: (1) emit a span event on the root marking `attribution.conflict=true` with both the tree-sum and root-authoritative values; (2) set the exported cost attribute to the root-authoritative figure only; (3) preserve descendant usage as a non-additive breakdown under a namespaced attribute (`agent.usage.breakdown.*`) that ..."
  },
  "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": "4b178e68800ef081414fa9f954ffcf30b2c6e90373c73b99ca2e2c057d79be25",
    "verified_classes": [
      "GenAIAttributionConflict",
      "SpanUsage"
    ],
    "verified_functions": [
      "close_span_tree"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAIAttributionConflict"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
