{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-a-single-genai-span-for-a-multi-turn-tool-calling-exchange-token-accounting-and-parent-context-divergence-at-the-o",
  "title": "What happens when an instance emits a single GenAI span for a multi-turn tool-calling exchange: token accounting and parent-context divergence at the OpenTelemetry GenAI semantic convention boundary",
  "date_of_record": "2026 November 15",
  "scope": "Applies to services instrumenting LLM calls, tool invocations, and agent-to-agent handoffs under the OpenTelemetry GenAI semantic conventions (`gen_ai.*`), specifically when one logical request triggers more than one model call or tool round-trip. Does not apply to single-shot completions with no tool calls, nor to pure infrastructure spans (`http.*`, `rpc.*`) that carry no `gen_ai.*` attributes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-single-genai-span-for-a-multi-turn-tool-calling-exchange-token-accounting-and-parent-context-divergence-at-the-o.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-single-genai-span-for-a-multi-turn-tool-calling-exchange-token-accounting-and-parent-context-divergence-at-the-o.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-a-single-genai-span-for-a-multi-turn-tool-calling-exchange-token-accounting-and-parent-context-divergence-at-the-o.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1377,
    "python_slice_tokens": 306,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a *chat inference operation* (`gen_ai.operation.name = chat`) as a leaf span whose `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` describe **one** model round-trip. A *tool call* is modeled as either an `execute_tool` span or an event/attribute on the parent chat span. A *multi-agent handoff* is modeled as a...",
    "what_was_observed": "A tool-orchestrating agent (three sequential tool calls, four model round-trips) was instrumented with a single wrapping `chat` span. Observed consequences: - **Token double-counting under fan-out.** `gen_ai.usage.input_tokens` was recorded as the sum of all four requests. A cost dashboard that multiplied `input_tokens × price` per span attributed the full loop cost to the *first* model's price tier, overstating spen...",
    "condition_of_validity": "The one-span-per-loop model is only valid when **all** of the following hold: 1. Exactly one model round-trip occurs (no tool calls, or tool calls executed outside the span's temporal bounds). 2. All token usage is attributable to a single `gen_ai.request.model` and a single `gen_ai.response.model`. 3. No child span is emitted whose `start_time` exceeds the ...",
    "decision_boundary": "Emit a **single** `chat` span only for atomic, single-round inference. Emit a **span per round-trip** (plus `execute_tool` children) whenever `finish_reason == tool_calls` triggers further work, or whenever the loop crosses model boundaries, or whenever a sub-agent is invoked. The decision hinges on whether the span's token counters can be honestly attribute...",
    "operational_effect": "Correct decomposition restores: per-round cost attribution, valid latency decomposition (time-to-first-token vs. tool execution vs. subsequent rounds), stable parent context for retries and sampling, and reconstructable causality for multi-agent traces. The cost is span cardinality — a 4-round loop yields 4 chat spans + 3 tool spans instead of 1 — which is t..."
  },
  "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": "77edad61cc4673a45e3a4e44cb40543443a88553caf5d5fc3923885c3cbcf8b2",
    "verified_classes": [
      "GenAISpanModelingError",
      "GenAISpan"
    ],
    "verified_functions": [
      "validate_chat_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenAISpanModelingError"
    ],
    "sample_fail_closed_invariants": [
      "aggregate chat span has children but no round_index; sub-agent links cannot be resolved to a specific round-trip."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
