{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-treat-a-genai-span-s-parent-child-topology-when-a-tool-call-span-outlives-its-enclosing-agent-invocation",
  "title": "How should an instance treat a GenAI span's parent-child topology when a tool-call span outlives its enclosing agent invocation",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans under the `gen_ai.*` semantic conventions and allows an LLM invocation span to close before the tool-call spans it spawned have terminated (async tools, deferred execution, human-in-the-loop pauses, retry queues). Does not apply to fully synchronous request/response tool loops where every child span is guaranteed to end before its parent.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-genai-span-s-parent-child-topology-when-a-tool-call-span-outlives-its-enclosing-agent-invocation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-genai-span-s-parent-child-topology-when-a-tool-call-span-outlives-its-enclosing-agent-invocation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-genai-span-s-parent-child-topology-when-a-tool-call-span-outlives-its-enclosing-agent-invocation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1914,
    "python_slice_tokens": 355,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *what* a span means (`gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`) but they say almost nothing normative about *span lifetime relative to topology*. The tracing SDK enforces one hard invariant—a child's `end_time` must not precede its `start_time`, and on many exporte...",
    "what_was_observed": "An agent runtime invoked a model with a `gen_ai.operation.name = \"chat\"` span (`span_id = A`). The model returned a tool call. The runtime opened a `gen_ai.operation.name = \"execute_tool\"` span as a child of `A` (`span_id = B`, `parent_span_id = A`) and dispatched the tool to an async worker. The model invocation span `A` then ended—correctly, because the model's turn was complete and its token accounting was final. ...",
    "condition_of_validity": "The parent-child edge from tool span to invocation span is only *sound* when all of the following hold: - The tool executes synchronously within the model's turn, so `B.end ≤ A.end`. - The tool result is fed back into the *same* invocation context (single-turn tool use). - No process boundary is crossed between `A.end` and `B.end`. When any of these fails—as...",
    "decision_boundary": "The runtime must decide, at tool-dispatch time, whether the tool will complete before the invocation span closes. It cannot know this in general. The decision boundary is therefore **the moment of dispatch**: - If the tool is dispatched *synchronously* (the invocation span's context manager has not exited), emit a parent edge. Acceptable. - If the tool is di...",
    "operational_effect": "The practical consequence is that **trace topology is not a reliable proxy for causal structure in GenAI workloads**, and any agent that consumes its own traces for learning, replay, or auditing must treat parent edges as advisory. Concretely: - Latency attribution must be computed from span `start`/`end` timestamps, not from subtree aggregation, because sub..."
  },
  "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": "ebb6b10b6d5b652f7f659ce0ebbb0fa56312b20d5f3d2be9616630e041d1f828",
    "verified_classes": [
      "TemporalContainmentViolation",
      "SpanRecord"
    ],
    "verified_functions": [
      "validate_genai_topology",
      "emit_tool_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TemporalContainmentViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
