{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-a-span-s-gen-ai-usage-input-tokens-as-non-reconcilable-with-the-sum-of-its-recorded-gen-ai-tool-child-spans",
  "title": "In what scenarios must an instance treat a span's `gen_ai.usage.input_tokens` as non-reconcilable with the sum of its recorded `gen_ai.tool` child spans",
  "date_of_record": "2026 November 25",
  "scope": "Applies to any instrumented agent that emits OpenTelemetry GenAI spans across a multi-turn tool-using loop, where parent model-invocation spans and child tool-execution spans are both exported and token accounting is derived by aggregating span attributes. Does not apply to single-shot completions with no tool children, nor to systems that record usage only at the root transaction span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-span-s-gen-ai-usage-input-tokens-as-non-reconcilable-with-the-sum-of-its-recorded-gen-ai-tool-child-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-span-s-gen-ai-usage-input-tokens-as-non-reconcilable-with-the-sum-of-its-recorded-gen-ai-tool-child-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-a-span-s-gen-ai-usage-input-tokens-as-non-reconcilable-with-the-sum-of-its-recorded-gen-ai-tool-child-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1678,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` on the model-invocation span as the tokens *the model consumed to produce that response*. They define `gen_ai.tool.name`, `gen_ai.tool.call.id`, and related attributes on tool-execution child spans, but they deliberately do **not** define a token cost for a tool span — a tool call consumes zer...",
    "what_was_observed": "An agent looped five turns against a retrieval tool. Each model-invocation span carried `gen_ai.usage.input_tokens` of roughly 1.2k, 2.4k, 3.6k, 4.8k, 6.0k — the prompt grows by the appended assistant message and tool result each turn. A naive reconciler summed the five parent spans and reported 18.0k input tokens for the task. The actual billed input was 18.0k — that part is correct, because each invocation genuinel...",
    "condition_of_validity": "Reconciliation of `input_tokens` against child tool spans is valid **only** under the conjunction: 1. Every tool child span is a leaf with no model-invocation descendants of its own (i.e., the tool did not spawn a sub-agent that itself emitted GenAI spans). If a tool internally invokes a model — a common \"retriever that reranks with an LLM\" pattern — that de...",
    "decision_boundary": "The boundary is whether the observer is computing **cost** or **attribution**. - For **cost**, aggregate `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` across spans where `gen_ai.operation.name == \"chat\"` (or the model-invocation equivalent) and the span has no model-invocation ancestor. Deduplicate by `gen_ai.response.id` where the backend may...",
    "operational_effect": "Systems that skip this partition exhibit a characteristic signature: reported cost scales super-linearly with loop depth and with fan-out width, while the invoice scales linearly with depth and is flat in fan-out. The divergence is invisible in aggregate (both grow) and only appears when you regress reported cost against `turn_count` versus `turn_count × fan..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "5ea3b4bde49ba490f25e7931dd6f4674f0a629fffa608b946761ef3e33fdfd04",
    "verified_classes": [
      "TokenReconciliationError",
      "Span"
    ],
    "verified_functions": [
      "reconcile_cost",
      "attribute_tool_cost",
      "has_chat_ancestor"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
