{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-re-parented-mid-execution",
  "title": "Where must an instance reconcile OpenTelemetry GenAI token accounting when a tool-call span is re-parented mid-execution?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.*` attributes) and that can re-parent or re-emit spans when a tool call is retried, resumed from checkpoint, or handed off to a sub-agent. Does not apply to single-shot inference calls with no tool loop and no span mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-re-parented-mid-execution.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-re-parented-mid-execution.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-token-accounting-when-a-tool-call-span-is-re-parented-mid-execution.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1557,
    "python_slice_tokens": 284,
    "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 a single model invocation, and `gen_ai.operation.name` as the discriminator between `chat`, `execute_tool`, and `invoke_agent`. The convention implicitly assumes a span is emitted exactly once, by the component that performed the wo...",
    "what_was_observed": "A tool-calling agent executed `search_corpus`. The `execute_tool` span carried `gen_ai.operation.name=execute_tool`, `gen_ai.tool.name=search_corpus`, and — incorrectly but commonly — the token usage of the *model call that decided to invoke the tool*: `gen_ai.usage.input_tokens=1840`, `gen_ai.usage.output_tokens=96`. The tool call timed out at the transport layer. The runtime retried it under a `resume` path and, be...",
    "condition_of_validity": "The double-count is only bounded — not eliminated — under the following conjunction, and collapses to unbounded double-counting when any conjunct fails: - The `execute_tool` span MUST NOT carry `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`. Per the conventions, usage belongs to the model-invocation span (`chat`), not the tool span. The token cos...",
    "decision_boundary": "The boundary is: **does the re-parenting event move a span that owns `gen_ai.usage.*`, or a span that does not?** - If the re-parented span is a `chat` span that legitimately owns usage, re-parenting is safe *only if* the collector aggregates by `gen_ai.operation.name` and the span is not re-emitted. Re-emission without idempotency key ⇒ double count. - If t...",
    "operational_effect": "Enforcing the boundary changes three things: (1) cost dashboards stop inflating on retries, because tool spans no longer contribute tokens and re-emitted chat spans collapse by key; (2) resume paths must explicitly re-derive `gen_ai.usage.*` on the resumed `invoke_agent` span from post-resume model calls, which surfaces the previously silent zero-token resum..."
  },
  "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": "ec53f525e068f45a93304c47857413eefc449bb662322200aaad7d1608dbdaec",
    "verified_classes": [
      "GenAiSpanAttributionError"
    ],
    "verified_functions": [
      "assert_reparentable",
      "reparent",
      "aggregate_usage"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAiSpanAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
