{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-token-accounting-before-emitting-a-parent-agent-span",
  "title": "Where must an instance reconcile OpenTelemetry GenAI tool-call spans against token accounting before emitting a parent agent span?",
  "date_of_record": "2026 November 23",
  "scope": "Applies to services emitting OpenTelemetry GenAI semantic-convention spans (agent, LLM, tool) where a single agent turn fans out into multiple tool calls and a single LLM completion, and where per-span `gen_ai.usage.*` token attributes are derived from provider responses. Does not apply to single-shot, tool-free LLM calls, nor to streaming-only traces where usage is reported asynchronously after span end.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-token-accounting-before-emitting-a-parent-agent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-token-accounting-before-emitting-a-parent-agent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-tool-call-spans-against-token-accounting-before-emitting-a-parent-agent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1127,
    "python_slice_tokens": 149,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage as a *per-inference* property attached to the LLM span (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`), while tool calls are modeled as *sibling* spans under the agent span with `gen_ai.operation.name = \"execute_tool\"` and `gen_ai.tool.name` / `gen_ai.tool.call.id` attributes. There is no normative...",
    "what_was_observed": "In a multi-step agent (planner → tool executor → synthesizer) instrumented per semconv: - The planner LLM span reported `input_tokens=812`, `output_tokens=140` (proposing a tool call). - The tool span carried `gen_ai.tool.call.id` and returned a 9 KB payload. - The synthesizer LLM span reported `input_tokens=812`, `output_tokens=95` — the orchestrator had *re-sent the original prompt* rather than appending the tool r...",
    "condition_of_validity": "A parent agent span may legitimately report a rollup of descendant `gen_ai.usage.*` **only if** all three hold: 1. Every tool result consumed by a downstream completion appears verbatim in that completion's input, so its tokens are counted on the child LLM span. 2. No prompt-cache read spans a boundary between sibling LLM spans such that the same cached pref...",
    "decision_boundary": "The correct decision at span-emit time is a hard gate, not a heuristic: - If the set of `gen_ai.tool.call.id` values on child tool spans is not a subset of the tool-call ids referenced by the child LLM spans' requests → **do not roll up**; emit the agent span with no `gen_ai.usage.*` and record a `reconciliation.failed` event. - If any child LLM span reports...",
    "operational_effect": "Emitting an unreconciled rollup produces cost dashboards that drift from invoices by the size of tool payloads — a drift that grows with tool verbosity, not with model usage, so it evades per-model anomaly detection. Downstream budget enforcers keyed on the parent span then either throttle healthy agents or fail to throttle runaway ones. The gate above conve..."
  },
  "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": "d7a9279ebf6e9f48aea2bff0352decc0e675594e11381e5de913a282a4b80f85",
    "verified_classes": [
      "TokenReconciliationError"
    ],
    "verified_functions": [
      "rollup_agent_usage"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenReconciliationError"
    ],
    "sample_fail_closed_invariants": [
      "shared cached prefix across sibling LLM spans; summing input_tokens double-counts cache reads"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
