{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-orphaned-tool-call-spans-from-corrupting-genai-trace-causality-under-concurrent-sub-agent-fan-out",
  "title": "Which invariants prevent orphaned tool-call spans from corrupting GenAI trace causality under concurrent sub-agent fan-out",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that emits OpenTelemetry `gen_ai.*` spans where a single model invocation (`gen_ai.operation.name = \"chat\"`) fans out to N tool-call spans (`gen_ai.operation.name = \"execute_tool\"`) that are executed concurrently by sub-agents and must be parented under the originating invocation span. Does not apply to purely sequential single-tool agents or to runtimes that flatten all tool calls into a single span with `gen_ai.tool.call.id` attributes only.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-tool-call-spans-from-corrupting-genai-trace-causality-under-concurrent-sub-agent-fan-out.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-tool-call-spans-from-corrupting-genai-trace-causality-under-concurrent-sub-agent-fan-out.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-tool-call-spans-from-corrupting-genai-trace-causality-under-concurrent-sub-agent-fan-out.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1687,
    "python_slice_tokens": 237,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.tool.call.id` as a correlation attribute, not a causal link. The causal link is carried by the OTel span parent/child relationship (`parent_span_id`). These two channels are maintained by different code paths: the attribute is written by the tool executor at completion time, while the parent link is written by th...",
    "what_was_observed": "A research-orchestrator agent ran a `chat` invocation that streamed three `tool_use` blocks (`search`, `fetch`, `summarize`). The runtime used a thread pool of size 3 to execute them concurrently. Each worker thread lazily created its `execute_tool` span *inside* the worker, after receiving the parsed tool arguments, using `opentelemetry.context.attach()` on a context captured from the parent thread. The captured con...",
    "condition_of_validity": "The invariant that must hold: **for every `execute_tool` span S with `gen_ai.tool.call.id = C`, there exists exactly one `chat` span P such that (a) `S.parent_span_id = P.span_id`, (b) `P.start_time <= S.start_time`, and (c) `S.end_time <= P.end_time`.** Condition (c) is the one that fails here, and it is the one nobody checks, because the OTel spec permits ...",
    "decision_boundary": "The boundary is whether the runtime treats the model invocation span as a *scoped event* (ends at last token) or as a *transaction* (ends at last dependent completion). The GenAI conventions are written as if it were an event — `gen_ai.usage.output_tokens` is a completion-time attribute, and `chat` spans are expected to be short. But the tool-call fan-out ma...",
    "operational_effect": "The operational consequence is that trace-based verification of tool provenance becomes unsound under fan-out unless the bracket invariant is enforced at span-emission time. An auditor that trusts `parent_span_id` alone will accept causally invalid traces; an auditor that additionally checks `S.end_time <= P.end_time` will *reject* valid traces from event-se..."
  },
  "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": "4e47ba1d81ad1d439ba08f8ad8a0d0f6c02d57bca87c5deb9ba26a8ead8deda2",
    "verified_classes": [
      "CausalityInvariantError",
      "Span"
    ],
    "verified_functions": [
      "assert_tool_span_causality"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "CausalityInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
