{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-emit-a-coherent-span-tree-yet-lose-the-parent-child-linkage-between-an-agent-invocation-span-and-its-tool-call-child-spans-when-t",
  "title": "Why does an instance emit a coherent span tree yet lose the parent-child linkage between an agent invocation span and its tool-call child spans when the tool executes asynchronously across a context re-entry boundary?",
  "date_of_record": "2026 November 24",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.agent.invoke`, `gen_ai.tool.call`, `gen_ai.usage.input_tokens`/`output_tokens`) where tool execution is dispatched through an async executor, thread pool, or message queue and rejoins the agent loop after a context switch. Does not apply to fully synchronous in-process tool calls that execute within the same active span context.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-coherent-span-tree-yet-lose-the-parent-child-linkage-between-an-agent-invocation-span-and-its-tool-call-child-spans-when-t.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-coherent-span-tree-yet-lose-the-parent-child-linkage-between-an-agent-invocation-span-and-its-tool-call-child-spans-when-t.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-a-coherent-span-tree-yet-lose-the-parent-child-linkage-between-an-agent-invocation-span-and-its-tool-call-child-spans-when-t.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1537,
    "python_slice_tokens": 194,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A span tree that *looks* correct in the collector — every span has a `trace_id`, timestamps nest cleanly, token attributes are populated — is not the same as a span tree whose parent-child edges were established by the actual execution context rather than by wall-clock inference. The failure mode here is not a missing span or a dropped export. It is a **sile...",
    "what_was_observed": "An agent invocation span (`gen_ai.operation.name = \"invoke_agent\"`, span A) at `t0` dispatches three tool calls. Two execute synchronously and correctly parent to A. The third is dispatched to an async executor because the tool is a long-running retrieval. The executor's `submit()` captures the current `contextvars.Context` at dispatch time — which is correct — but the worker thread's instrumentation library initiali...",
    "condition_of_validity": "The invariant that must hold: **for every `gen_ai.tool.call` span, the resolved parent span must be the `gen_ai.agent.invoke` span (or a descendant of it) whose reasoning step emitted the tool dispatch.** This holds only when the tool-call span is created with an explicit parent context that was captured at the dispatch site and *re-injected* at the worker e...",
    "decision_boundary": "The boundary is between **trace-ID propagation** and **span-parent propagation**. Trace-ID propagation is resilient: it rides on the `traceparent` header or the captured `Context`'s trace state and survives most boundaries. Span-parent propagation is fragile: it requires the *active span* to be present in the context at span-creation time, and that active sp...",
    "operational_effect": "Downstream, this produces three concrete operational failures. First, **token attribution collapses**: per-agent cost queries that aggregate `gen_ai.usage.*` over the agent span's descendants undercount by the full cost of every async tool call, which for retrieval-heavy agents is often the majority of input tokens. Second, **latency decomposition breaks**: ..."
  },
  "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": "e8e28a3dbb0f62a2f3e062a544a9bc803161a1f6d018a0b868f56d26d2c04992",
    "verified_classes": [
      "OrphanedToolCallError",
      "Span"
    ],
    "verified_functions": [
      "validate_tool_call_parentage",
      "audit_trace"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "OrphanedToolCallError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
