{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-genai-agent-span-misattribution-when-parallel-tool-call-fan-out-exceeds-the-parent-span-s-emit-window",
  "title": "Which invariants prevent GenAI Agent Span Misattribution When Parallel Tool-Call Fan-Out Exceeds the Parent Span's Emit Window",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents emitting OpenTelemetry spans under the `gen_ai.*` semantic conventions (GenAI semconv ≥ v1.29) where a single agent turn fans out to concurrent tool calls whose completions may be reordered, dropped, or emitted after the parent agent span has ended. Does not cover single-threaded linear tool-call chains, or spans emitted by a gateway/proxy that owns its own trace lifecycle.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-span-misattribution-when-parallel-tool-call-fan-out-exceeds-the-parent-span-s-emit-window.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-span-misattribution-when-parallel-tool-call-fan-out-exceeds-the-parent-span-s-emit-window.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-span-misattribution-when-parallel-tool-call-fan-out-exceeds-the-parent-span-s-emit-window.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2049,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The `gen_ai.agent.*` span hierarchy assumes a **parent-child causal ordering**: the agent span (carrying `gen_ai.agent.name`, `gen_ai.agent.id`, `gen_ai.operation.name=invoke_agent`) opens, emits child `gen_ai.tool.call` spans, and closes only after all children have been emitted with matching `parent_span_id`. The GenAI conventions treat the agent span's `e...",
    "what_was_observed": "An agent executing a single `invoke_agent` turn dispatched four parallel tool calls (`search`, `fetch`, `summarize`, `write`). The agent span opened at `t0`, spawned all four children, and the orchestrator awaited the fastest three. The fourth (`write`, a slow filesystem tool) exceeded the orchestrator's internal 800ms soft deadline; the orchestrator treated it as backgrounded, closed the agent span at `t0+812ms`, an...",
    "condition_of_validity": "The deferred-finalization invariant is *required* (not merely recommended) whenever all of the following hold: 1. The agent span is the accounting owner of `gen_ai.usage.*` and tool spans carry their own `gen_ai.usage.*` that must roll up to the same turn. 2. Tool calls execute concurrently or asynchronously, so completion order ≠ emission order. 3. Any cons...",
    "decision_boundary": "The decision is whether to (a) block parent closure on child export acknowledgment, or (b) accept orphan-by-arrival children and make consumers join by `trace_id` + `gen_ai.tool.call.id` rather than by parent `end_time`. Choose (a) **deferred finalization** when the agent span is the sole accounting owner and turn-level token reconciliation must be exact—i.e...",
    "operational_effect": "With deferred finalization enforced, the agent span's `end_time` becomes `max(child.ack_time)` rather than the orchestrator's soft deadline, and `gen_ai.usage.*` is written only after the last child ack. A slow `write` tool extends the turn's accounting window by ~1.1s but keeps the turn record atomic: four tool spans, one usage total, no cross-window bleed...."
  },
  "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": "f507da26b43a63fe9be544a253236d43b8ddf63bf6069c457535e14526c7389a",
    "verified_classes": [
      "SpanEmitWindowViolation",
      "AgentSpan"
    ],
    "verified_functions": [
      "close_agent_turn",
      "spawn_tool_call",
      "ack_tool_call_export",
      "finalize"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanEmitWindowViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
