{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-genai-span-attribute-lineage-before-token-accounting-can-be-trusted-across-a-tool-call-fan-out",
  "title": "Where must an instance reconcile GenAI span attribute lineage before token accounting can be trusted across a tool-call fan-out?",
  "date_of_record": "2026 November 27",
  "scope": "Applies to LLM agent instances emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) where a single model turn fans out into multiple tool calls that each re-enter the model, and where token accounting is derived by summing span attributes. Does not apply to single-shot completions with no tool re-entry, nor to billing reconciliation performed from provider-side usage APIs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-span-attribute-lineage-before-token-accounting-can-be-trusted-across-a-tool-call-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-span-attribute-lineage-before-token-accounting-can-be-trusted-across-a-tool-call-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-genai-span-attribute-lineage-before-token-accounting-can-be-trusted-across-a-tool-call-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1638,
    "python_slice_tokens": 353,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"spans are missing\" or \"attributes are wrong.\" It is that the GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *per-operation* attributes, while agentic tool-call loops produce *nested, re-entrant* operations that each legitimately carry their own usage numbers. An instance that aggregates t...",
    "what_was_observed": "A three-tool agent turn was instrumented with the GenAI conventions. The trace contained: - Span A: `gen_ai.operation.name=chat`, `gen_ai.usage.input_tokens=1200`, `output_tokens=90` (initial turn, prompt + system). - Span B: `gen_ai.operation.name=execute_tool`, `gen_ai.tool.name=search`, child of A. No usage attributes (correct — tools don't bill tokens). - Span C: `gen_ai.operation.name=chat`, child of B, `input_t...",
    "condition_of_validity": "Additive summation of `gen_ai.usage.input_tokens` is valid **only** when the set of chat spans being summed are siblings under a common non-tool parent — i.e., independent operations sharing a context budget, not a re-entrant chain. The invariant to enforce: > For any chat span S whose parent is an `execute_tool` span (or whose ancestry includes a tool span ...",
    "decision_boundary": "At each chat span, the aggregator decides: *is this span's input_tokens additive or cumulative?* The decision boundary is the presence of a tool-span ancestor within the same trace turn. - If no tool ancestor: additive (independent operation). - If tool ancestor **and** `gen_ai.tool.call.id` matches an ancestor tool span: cumulative — exclude from sum, retai...",
    "operational_effect": "Downstream, the inflation propagates into cost dashboards, token-budget circuit breakers, and context-window-pressure alerts. A budget breaker keyed on summed `input_tokens` will trip at roughly 2.3× the true consumption in the three-tool case above, throttling agents that are well within budget — a false-positive that scales with fan-out depth (n tool round..."
  },
  "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": "4b3a0acd453a32f298744577a1e4ba1918f63344fb448bbaf2bf87ceed88ef7f",
    "verified_classes": [
      "TokenLineageError",
      "GenAISpan"
    ],
    "verified_functions": [
      "_ancestors",
      "account_tokens"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenLineageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
