{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-opentelemetry-genai-spans-across-a-tool-call-boundary-without-reconciling-token-accounting-against-the-parent-agen",
  "title": "What happens when an instance emits OpenTelemetry GenAI spans across a tool-call boundary without reconciling token accounting against the parent agent span",
  "date_of_record": "2026 November 20",
  "scope": "Applies to LLM-backed agent runtimes that emit OpenTelemetry GenAI semantic convention spans (`gen_ai.*` attributes) per tool call and per model invocation, and that aggregate token counts upward to a parent agent span. Does not apply to single-shot inference services with no tool loop, nor to runtimes that delegate accounting entirely to a gateway that owns the span tree.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-across-a-tool-call-boundary-without-reconciling-token-accounting-against-the-parent-agen.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-across-a-tool-call-boundary-without-reconciling-token-accounting-against-the-parent-agen.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-opentelemetry-genai-spans-across-a-tool-call-boundary-without-reconciling-token-accounting-against-the-parent-agen.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1606,
    "python_slice_tokens": 222,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define token attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) at the *inference span* level, and separately define agent/tool spans (`gen_ai.agent.*`, `gen_ai.tool.*`) that describe orchestration. The conventions deliberately do **not** mandate how child inference spans roll up into a parent agent span. Th...",
    "what_was_observed": "A three-step agent (plan → tool call → synthesize) was instrumented with one `gen_ai.agent.invoke` parent span and child spans per model call and per tool call. The tool call to an external HTTP endpoint returned a 503 on the first attempt; the runtime's retry wrapper re-issued the request. The second attempt succeeded. The runtime emitted **two** `gen_ai.tool.execute` spans (correct—both attempts happened) but only ...",
    "condition_of_validity": "The roll-up invariant holds **only if** every inference span that consumed billable tokens is represented exactly once in the child set, and no inference span represents tokens that were not billed. This is violated by three concrete conditions: 1. **Retry-with-cache:** a failed attempt whose tokens were charged but whose span was suppressed because the *log...",
    "decision_boundary": "The architectural guardrail is a **span-emission contract** enforced at the instrumentation boundary, not at the aggregation layer: - Every billable token event MUST produce exactly one inference span, even if the logical operation is retried. The span carries `gen_ai.request.is_retry = true` (or equivalent custom attribute) and the retry index. - The parent...",
    "operational_effect": "Without the contract, three failure modes propagate: - **Budget enforcement drifts.** Per-tenant caps either over-fire (killing sessions that were under budget) or under-fire (billing overruns). The drift is non-stationary because retry rates vary by tool and by provider. - **Cost attribution becomes unauditable.** Finance cannot reconcile span-derived cost ..."
  },
  "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": "fc3f677fd73215a781fc1a75d7ed20835af8e912a8d1bb0c3bf42206df0099c2",
    "verified_classes": [
      "TokenAccountingMismatch",
      "TokenEvent",
      "AgentSpan"
    ],
    "verified_functions": [
      "reconcile"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenAccountingMismatch"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
