{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-emit-orphaned-tool-call-spans-when-an-agent-resumes-from-a-checkpoint-mid-tool-execution",
  "title": "Why does an instance emit orphaned tool-call spans when an agent resumes from a checkpoint mid-tool-execution",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agents that persist execution state (checkpoints, resumable traces) between tool invocations and emit OpenTelemetry GenAI spans per the `gen_ai.*` semantic conventions. Does not apply to stateless single-shot inference calls or to agents whose checkpoint granularity is the whole task.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-orphaned-tool-call-spans-when-an-agent-resumes-from-a-checkpoint-mid-tool-execution.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-orphaned-tool-call-spans-when-an-agent-resumes-from-a-checkpoint-mid-tool-execution.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-emit-orphaned-tool-call-spans-when-an-agent-resumes-from-a-checkpoint-mid-tool-execution.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2022,
    "python_slice_tokens": 309,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool call as a *nested span pair*: the model's request (`gen_ai.operation.name = \"chat\"`) and, as a child, one span per tool invocation carrying `gen_ai.tool.name`, `gen_ai.tool.call.id`, and `gen_ai.usage.*` token attributes. The invariant the conventions assume is **span-tree locality**: a tool span's parent is the mo...",
    "what_was_observed": "A resumable agent (LangGraph-style checkpointer, tool calls as durable nodes) was instrumented with GenAI spans. Under a fault-injection harness, the process was killed with SIGKILL at a uniformly sampled point inside the window between \"model returned a tool-call decision\" and \"tool result written back to checkpoint.\" On restart, the agent rehydrated from the last checkpoint and continued. Observed in the exported O...",
    "condition_of_validity": "The orphaned-span failure is *bounded and preventable* only under the following condition: **the span context of the requesting model turn must be persisted into the checkpoint alongside the logical tool-call decision, and on resume the tool span must be emitted as a child of a re-materialized (or explicitly linked) parent that carries the original `trace_id...",
    "decision_boundary": "The operator/architect must decide, at instrumentation design time, which side of this line the system sits on: - **Below the boundary (accept orphans):** checkpoint granularity is coarser than tool execution, OR the agent tolerates replayed model turns and downstream consumers dedupe on `call.id` rather than span parentage. Orphaned tool spans are then a *k...",
    "operational_effect": "With trace context persisted and replay-deduped, the orphan rate dropped from 11.4% to 0 in the harness, and the re-rooted/dangling-parent split collapsed to zero because every resumed tool span had a resolvable, correctly-typed parent. The cost: the checkpoint schema grew by the serialized `SpanContext` per pending call (~64 bytes) and the resume path gaine..."
  },
  "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": "c30f075837b548ecad94544a048b9a6f43b2e2bb03ae37f0e77d321918ae7156",
    "verified_classes": [
      "OrphanedToolSpanError",
      "SpanContext",
      "CheckpointedToolCall"
    ],
    "verified_functions": [
      "resume_tool_span",
      "emit_usage"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "OrphanedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
