{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-tool-call-spans-when-token-accounting-diverges-from-parent-trace-propagation",
  "title": "How should an instance reconcile OpenTelemetry GenAI tool-call spans when token accounting diverges from parent trace propagation",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for tool calls and propagate W3C trace context across model invocations, tool sandboxes, and sub-agent handoffs. Does not apply to single-process, single-span inference logging where no cross-context propagation occurs, nor to non-OTel observability pipelines.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-spans-when-token-accounting-diverges-from-parent-trace-propagation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-spans-when-token-accounting-diverges-from-parent-trace-propagation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-spans-when-token-accounting-diverges-from-parent-trace-propagation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2165,
    "python_slice_tokens": 386,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two independent things an agent trace is supposed to represent, and they are conflated by nearly every GenAI instrumentation layer shipped today: 1. **Causal propagation** — the W3C `trace_id`/`span_id`/`traceparent` chain that asserts \"this tool call happened because of that model turn, which happened because of that user request.\" 2. **Token acco...",
    "what_was_observed": "A planner agent (span `A`, `gen_ai.operation.name=chat`) emits a tool call to a `code_exec` sandbox. The sandbox runs a sub-agent that makes two additional model calls (a patch generator and a verifier). Instrumentation is straightforward: each model call opens a child span with `traceparent` derived from the current context, and each sets `gen_ai.usage.*` from the provider response. The failure trace: - Span `A` rec...",
    "condition_of_validity": "The reconciliation invariant — \"sum of `gen_ai.usage.*` over a span subtree equals provider-billed usage for the model calls causally initiated within that subtree\" — holds only when all four of the following are true: 1. **Context freshness.** Every child span is created from a context snapshot taken *after* the parent's tool-call arguments were finalized. ...",
    "decision_boundary": "The boundary an operator must draw is between **accepting the trace as a causal record** and **accepting it as an accounting record**. These diverge at exactly one decision point: whether a child span's `traceparent` was minted from a context that post-dates the parent's usage finalization. - If the child's context is fresh (snapshot taken after parent respo...",
    "operational_effect": "The consequence of ignoring this boundary is a silent, systematic cost-attribution drift that compounds with agent depth. Each nested tool-call layer that forks a sandbox with a stale context adds one more mis-attributed subtree. In a three-level planner→executor→verifier topology with retries, observed drift reached 18–34% of true billed tokens depending on..."
  },
  "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": "bd97e5b4ad8958142cb7818ac83d01337d15a60f9eecfe7483814fcfabdddf01",
    "verified_classes": [
      "TraceAccountingDivergence",
      "GenAISpan",
      "TraceReconciler"
    ],
    "verified_functions": [
      "__init__",
      "admit",
      "subtree_usage"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TraceAccountingDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
