{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-an-opentelemetry-genai-span-for-a-tool-call-that-never-resolves-the-orphaned-span-invariant-and-its-silent-corrupt",
  "title": "What happens when an instance emits an OpenTelemetry GenAI span for a tool call that never resolves: the orphaned-span invariant and its silent corruption of agent trace continuity",
  "date_of_record": "2026 November 26",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.*`) around tool invocations, particularly when a tool call is dispatched but the span's end event is lost to timeout, cancellation, or process death. Does not apply to purely in-process metric-only instrumentation or to spans that are never exported.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-an-opentelemetry-genai-span-for-a-tool-call-that-never-resolves-the-orphaned-span-invariant-and-its-silent-corrupt.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-an-opentelemetry-genai-span-for-a-tool-call-that-never-resolves-the-orphaned-span-invariant-and-its-silent-corrupt.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-an-opentelemetry-genai-span-for-a-tool-call-that-never-resolves-the-orphaned-span-invariant-and-its-silent-corrupt.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2161,
    "python_slice_tokens": 373,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A tool-call span is not a log line. It is a *bracketed* temporal object: it asserts that an interval existed, that the interval began at a known time, and that the interval *closed*. The GenAI semantic conventions make this bracketing load-bearing by attaching `gen_ai.tool.call.id` to the span and expecting that the same call ID will appear on any subsequent...",
    "what_was_observed": "A single-agent runtime using a ReAct-style loop emitted, per turn, one `gen_ai.operation.name: execute_tool` span and one `gen_ai.operation.name: chat` span, linked by `gen_ai.tool.call.id`. The runtime wrapped each tool dispatch in `tracer.start_as_current_span(...)` with a `contextvars`-based current-span stack. On turn 7, the tool (an HTTP fetch) exceeded its 30s deadline. The agent's deadline handler raised a `Ti...",
    "condition_of_validity": "The orphaned-span failure is bounded by three conditions, all of which must hold for the corruption to propagate: 1. **The span is exported before it ends.** This happens under batch processors with a short `schedule_delay_millis`, under synchronous `SimpleSpanProcessor` on a start event, or under any exporter that flushes on a context switch. If spans are o...",
    "decision_boundary": "The boundary is between *treating span arrival as evidence of completion* and *treating terminal status as evidence of completion*. Concretely: - **Below the boundary (safe):** The agent runtime guarantees that every started `execute_tool` span is closed in a `finally` block, and on cancellation it sets `otel.status_code = ERROR`, `error.type = \"timeout\"`, a...",
    "operational_effect": "The practical consequences, in order of severity: 1. **Causal mis-attribution.** A follow-up `chat` span that consumed a timeout message is joined to no tool call, so the agent's reasoning appears to have hallucinated a tool result rather than having received a timeout. Post-mortems chase the model instead of the deadline handler. 2. **Coverage-metric drift...."
  },
  "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": "91376345df36184d4421a4a060f8397635985f317dbae50ac1ca48760226b9ce",
    "verified_classes": [
      "OrphanedToolSpanError",
      "GenAIToolSpan"
    ],
    "verified_functions": [
      "join_chat_to_tool",
      "close_span_on_cancellation",
      "close",
      "is_terminal"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "OrphanedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
