{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-opentelemetry-genai-tool-call-spans-from-silently-collapsing-parent-child-causality-during-concurrent-fan-out",
  "title": "Which invariants prevent OpenTelemetry GenAI tool-call spans from silently collapsing parent-child causality during concurrent fan-out",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agents that emit OTel GenAI semantic-convention spans (`gen_ai.*`) for a single logical agent turn that fans out into concurrent tool calls sharing one parent `invoke_agent` span. Does not apply to strictly sequential single-tool turns, nor to trace export backends (collector/Jaeger) — only to the instrumentation layer inside the agent runtime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-tool-call-spans-from-silently-collapsing-parent-child-causality-during-concurrent-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-tool-call-spans-from-silently-collapsing-parent-child-causality-during-concurrent-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-opentelemetry-genai-tool-call-spans-from-silently-collapsing-parent-child-causality-during-concurrent-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1857,
    "python_slice_tokens": 436,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **span identity** (a `SpanContext`: `trace_id` + `span_id`, immutable, assigned at span creation) and **span causality** (the parent-child link encoded as `parent_span_id` at creation time, and the *temporal ordering* the backend reconstructs from `start_time`/`end_time`). OTel GenAI conventions require every tool invo...",
    "what_was_observed": "A single agent turn issued five parallel tool calls via `asyncio.gather`. Instrumentation created the `invoke_agent` span, then created five `execute_tool` child spans inside each coroutine (correct `parent_span_id`). The agent coroutine returned as soon as `gather` resolved on the *fastest* results path because the tool wrapper used `asyncio.wait(..., return_when=FIRST_COMPLETED)` to support early-exit heuristics, t...",
    "condition_of_validity": "The invariant `child.start_time >= parent.start_time` AND `child.end_time <= parent.end_time` for every `execute_tool` child of an `invoke_agent` span holds **only if the parent span is closed strictly after every child it directly issued has closed** — i.e., the agent's `end_time` must be `>= max(child.end_time)` over all children created under it. This is ...",
    "decision_boundary": "The decision the instrumentation layer must make at fan-out time: **is the agent span allowed to close before all issued children close?** - If the agent semantics are \"I waited for all tools before deciding\" → parent MUST close after the child-close barrier. Enforce by tracking a per-agent live-child counter and refusing to end the span while `live_children...",
    "operational_effect": "Downstream consumers that assume interval containment (waterfall renderers, \"turn complete\" verifiers, auditor agents reconstructing causality, latency-attribution jobs summing child durations against parent duration) will misread the trace. The most damaging effect observed was **false partial-failure escalation causing a full retry of a turn whose tools ha..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "fce4522a8652af396c4e31e43bf489fc624e8783e215d5fd243694c9513dd2be",
    "verified_classes": [
      "TemporalContainmentViolation",
      "Span",
      "AgentSpanGuard"
    ],
    "verified_functions": [
      "assert_containment",
      "__init__",
      "open_agent",
      "register_child",
      "close_agent"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "TemporalContainmentViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
