{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tool-call-span-misattribution-across-multi-turn-agent-turns-under-opentelemetry-genai-semantic-conventions",
  "title": "Which invariants prevent tool-call span misattribution across multi-turn agent turns under OpenTelemetry GenAI semantic conventions",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents that emit OpenTelemetry GenAI spans (`gen_ai.*`) for a multi-turn conversation where each assistant turn may contain zero or more tool calls, and where tool results are fed back into a subsequent LLM call. Does not apply to single-shot RAG pipelines or to agents that emit only a single span per session.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-misattribution-across-multi-turn-agent-turns-under-opentelemetry-genai-semantic-conventions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-misattribution-across-multi-turn-agent-turns-under-opentelemetry-genai-semantic-conventions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tool-call-span-misattribution-across-multi-turn-agent-turns-under-opentelemetry-genai-semantic-conventions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1715,
    "python_slice_tokens": 307,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A tool-call span is not a child of \"the agent.\" It is a child of a *specific* LLM invocation that *requested* that tool call, and its result must be attributed back to exactly one subsequent LLM invocation that *consumed* it. The GenAI semantic conventions encode this contract through a small set of attributes — `gen_ai.operation.name`, `gen_ai.conversation....",
    "what_was_observed": "A planner agent (model `gpt-4o`, `gen_ai.operation.name=chat`) executed a 9-turn conversation. Turn 4 issued two parallel tool calls (`search`, `fetch_url`) with ids `call_a1` and `call_a2`. The tool executor ran them concurrently and emitted two `gen_ai.operation.name=execute_tool` spans. Both carried the correct `gen_ai.tool.call.id`. Both had `parent_span_id` set to the turn-4 chat span. So far, correct. Turn 5's ...",
    "condition_of_validity": "The invariant holds only when all of the following are true: 1. `gen_ai.tool.call.id` is treated as a globally unique, immutable identifier scoped to `(gen_ai.conversation.id, gen_ai.tool.call.id)`, and the orchestrator refuses to emit a tool span whose id is not present verbatim in the *preceding* LLM span's `gen_ai.prompt` messages. 2. Retries of an LLM in...",
    "decision_boundary": "The boundary is between *tracing as observation* and *tracing as control*. If spans are emitted purely for observability, a misattributed tool span is a data-quality defect: dashboards are wrong, but the agent still runs. If spans are consumed by the orchestrator itself — for example, a cost-budget guard that reads `gen_ai.usage.input_tokens` from the parent...",
    "operational_effect": "Enforcing the invariant changes three things: (a) the tool executor must reject any tool call whose id is not a verbatim substring of the immediately preceding chat span's serialized prompt — a cheap check that catches truncation and id-regeneration; (b) retries must be modeled as `retry.attempt` events on the original span, preserving `span_id`, so that too..."
  },
  "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": "938e65d2dc21812aa23bd0675df5e4087cf48676113d57208deaf82d0f0ac31f",
    "verified_classes": [
      "ToolCallAttributionError",
      "ChatSpan",
      "ToolCall"
    ],
    "verified_functions": [
      "validate_tool_call_attribution",
      "emit_tool_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ToolCallAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
