{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-tool-call-span-attributes-when-a-single-tool-invocation-produces-multiple-token-level-model-spans",
  "title": "How should an instance reconcile OpenTelemetry GenAI tool-call span attributes when a single tool invocation produces multiple token-level model spans",
  "date_of_record": "2026 November 13",
  "scope": "Applies to instrumented LLM services emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where tool calls and token accounting coexist on the same trace. Does not apply to pure completion spans without tool invocation, nor to provider-native proprietary telemetry that bypasses the OTel GenAI conventions.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-span-attributes-when-a-single-tool-invocation-produces-multiple-token-level-model-spans.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-span-attributes-when-a-single-tool-invocation-produces-multiple-token-level-model-spans.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-tool-call-span-attributes-when-a-single-tool-invocation-produces-multiple-token-level-model-spans.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1703,
    "python_slice_tokens": 394,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define two attribute families that look composable but are not orthogonal: tool-call attributes (`gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.operation.name = \"execute_tool\"`) and token-usage attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and the newer cache/reasoning counters). The non-obvious inv...",
    "what_was_observed": "On a production agent runtime using a streaming model with a tool-call loop, a single user turn produced: - One `chat` span (`gen_ai.operation.name = \"chat\"`) carrying `gen_ai.usage.input_tokens = 1840`, `output_tokens = 312`. - One `execute_tool` span with `gen_ai.tool.call.id = \"call_ab12\"`, and — because the SDK mirrored usage for local observability — `gen_ai.usage.input_tokens = 1840`, `output_tokens = 312` copi...",
    "condition_of_validity": "The invariant \"sum `gen_ai.usage.*` per `gen_ai.tool.call.id` yields billed tokens\" holds **only if** the following are simultaneously true: 1. Token attributes appear exclusively on `gen_ai.operation.name` spans of type `chat`/`text_completion` and never on `execute_tool` spans. 2. `gen_ai.tool.call.id` is attached to at most one model-inference span per lo...",
    "decision_boundary": "An instance must choose between two reconciliation strategies at the boundary: - **Ownership-by-operation:** Count tokens only on spans where `gen_ai.operation.name` is a model-inference operation (`chat`, `text_completion`, `embeddings`), and treat `gen_ai.tool.call.id` purely as a *correlation* key, never as an aggregation key for cost. This is correct whe...",
    "operational_effect": "The practical effect is that trace-derived cost dashboards systematically overcount during tool-heavy turns and undercount during sub-agent fan-out, and the two errors partially cancel, making the aggregate look plausible while per-tenant and per-tool breakdowns are wrong. Reconciliation against provider invoices fails intermittently, and the failure is misd..."
  },
  "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": "6adbc589a76c3563216900fa529fd53aff02d35e1f2914d3fb8735a35d0eb1ba",
    "verified_classes": [
      "ToolCallAttributionError",
      "Span"
    ],
    "verified_functions": [
      "attribute_tokens",
      "reconcile_against_invoice"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ToolCallAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
