{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-opentelemetry-genai-span-trees-from-silently-dropping-tool-call-causality-during-agent-turn-fan-out",
  "title": "Which invariants prevent OpenTelemetry GenAI span trees from silently dropping tool-call causality during agent turn fan-out",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.agent.*`, tool-call and agent-turn spans) where a single logical turn fans out into concurrent tool invocations whose spans are parented by a shared turn span. Does not apply to single-threaded synchronous tool loops with strictly serial execution, nor to tracing that uses only non-GenAI custom attributes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-trees-from-silently-dropping-tool-call-causality-during-agent-turn-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-trees-from-silently-dropping-tool-call-causality-during-agent-turn-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-span-trees-from-silently-dropping-tool-call-causality-during-agent-turn-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1620,
    "python_slice_tokens": 222,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing spans.\" It is **causal misattribution under fan-out**: the span tree remains structurally valid and every span is exported, yet the *parent-child edge* that should bind a tool result to the specific model turn that requested it is either (a) collapsed onto a single turn span, or (b) re-parented to whichever tool span the exporter'...",
    "what_was_observed": "An agent turn issues a model call that returns three tool calls in one assistant message (`tool_calls: [{id: \"call_a\"}, {id: \"call_b\"}, {id: \"call_c\"}]`). The runtime fans out: it spawns three concurrent async tasks, each of which opens a `gen_ai.operation.name=execute_tool` span. Because the runtime propagates OTel context via a contextvar (task-local, not inherited unless explicitly copied), the three tool spans do...",
    "condition_of_validity": "The invariant holds only under these conditions, and fails silently outside them: - **The turn span must remain the active parent for the entire duration of all tool calls it requested.** This means the turn span cannot be ended at model-response boundary; it must be closed after all descendant tool spans terminate. If the runtime treats the model call as th...",
    "decision_boundary": "The decision is between two span-modeling strategies at the fan-out point, and the boundary is *whether the turn span outlives its tool children*: - If the runtime can guarantee the turn span stays open across fan-out (structural parent + immutable per-task call ID), use the nested model: `turn → {tool_a, tool_b, tool_c}`, each child carrying its own `gen_ai...",
    "operational_effect": "Downstream, a verification replay that reconstructs the agent's causal graph from spans will diverge from the agent's actual execution trace. This is not a cosmetic tracing bug: in systems where the span tree is the audit substrate (safety review, incident reconstruction, or a verifier agent cross-checking a peer's tool use), a misattributed call ID means th..."
  },
  "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": "81fa5b26702407e3ac59b00ed89529b71edfbaa9f91598c3dceb967483c9d036",
    "verified_classes": [
      "SpanCausalityViolation",
      "TurnSpan",
      "ToolSpan"
    ],
    "verified_functions": [
      "validate_tool_span_causality",
      "emit_fanout"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanCausalityViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
