{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-abandon-opentelemetry-genai-span-nesting-to-preserve-tool-call-causality",
  "title": "When must an instance abandon OpenTelemetry GenAI span nesting to preserve tool-call causality",
  "date_of_record": "2026 November 28",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) for agent orchestration and tool invocation, where a single agent instance issues tool calls that may themselves spawn sub-agents or re-enter the same process. Does not apply to stateless single-shot inference servers that emit one span per request with no nested tool activity.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-opentelemetry-genai-span-nesting-to-preserve-tool-call-causality.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-opentelemetry-genai-span-nesting-to-preserve-tool-call-causality.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-opentelemetry-genai-span-nesting-to-preserve-tool-call-causality.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1777,
    "python_slice_tokens": 342,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a tool call as a child span of the agent span that issued it, linked by `parent_span_id` and tagged with `gen_ai.operation.name = \"execute_tool\"`. This nesting encodes a *causal* claim: the tool execution happened-because-of the agent turn. That claim is only valid when the parent span's lifetime strictly contains the chi...",
    "what_was_observed": "A multi-step agent (five tool calls per turn, sub-agent delegation on call three) emitted spans with a single `trace_id` per turn. On cold-start resume after a context-window checkpoint, the runtime rehydrated the agent state and continued execution. The resumed instance generated a *new* `trace_id` (the process had restarted; the tracer provider reinitialized). Tool calls issued after resume carried `parent_span_id`...",
    "condition_of_validity": "Strict GenAI span nesting (`tool_span.parent_span_id == agent_span.span_id`) is valid **if and only if** all three hold: - **Lifetime containment:** the agent span is open for the entire interval `[tool.start, tool.end]`. This fails whenever the agent span is closed to bound latency, or when the agent is checkpointed mid-turn. - **Identity stability:** the `...",
    "decision_boundary": "The runtime must evaluate a *nesting eligibility predicate* immediately before emitting any tool span: If `nest_tool_span` is false, emit the tool span with `parent=None`, set `trace_id` to the *current* tracer's trace, attach a `SpanLink` to the originating agent span context (which may be from a different trace), and stamp `gen_ai.agent.turn_id` and `gen_a...",
    "operational_effect": "Adopting the predicate changes three downstream computations: - **Cost attribution** moves from parent-walk to `turn_id` grouping, which is resume- and replay-stable. Per-tool token sums become correct across restarts. - **Error-compounding detection** must query `SpanLink` edges (or `turn_id` joins) rather than parent status, because the parent may not exis..."
  },
  "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": "639bc461000360371c892e2fd00deb75f33a8ea07c4609c0ec1fd84b193747c0",
    "verified_classes": [
      "DanglingParentSpanError",
      "SpanContext",
      "ExecutionState"
    ],
    "verified_functions": [
      "emit_tool_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "DanglingParentSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
