{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-the-silent-tool-span-orphan-when-a-genai-agent-aborts-mid-tool-call",
  "title": "How does an instance detect the Silent Tool-Span Orphan When a GenAI Agent Aborts Mid-Tool-Call",
  "date_of_record": "2026 November 16",
  "scope": "Applies to OpenTelemetry GenAI semantic conventions (agent spans, `execute_tool` child spans, and `gen_ai.usage.*` token metrics) emitted by agent runtimes that can cancel or crash between tool invocation and tool result. Does not apply to synchronous single-shot LLM calls with no tool loop, nor to runtimes that guarantee span closure via a supervisor process outside the instrumented boundary.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-silent-tool-span-orphan-when-a-genai-agent-aborts-mid-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-silent-tool-span-orphan-when-a-genai-agent-aborts-mid-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-silent-tool-span-orphan-when-a-genai-agent-aborts-mid-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1129,
    "python_slice_tokens": 163,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat an agent invocation as a parent span (`gen_ai.operation.name = \"invoke_agent\"`) with child `execute_tool` spans carrying `gen_ai.tool.name`, `gen_ai.tool.call.id`, and a result attribute. The naive invariant an operator assumes is: *every `execute_tool` span that starts will end, and its parent agent span will aggregate i...",
    "what_was_observed": "During a rollback of a tool-augmented agent, a subset of `invoke_agent` spans showed `status = OK` with `gen_ai.usage.output_tokens` values that were internally consistent but *lower than the sum of their child `execute_tool` spans' recorded token attributes*. Cross-referencing by `gen_ai.tool.call.id` revealed child spans whose `end_time` was absent (exported as incomplete) or whose `status.message` contained a canc...",
    "condition_of_validity": "This failure mode is *only* detectable when all three hold: 1. The runtime emits a stable `gen_ai.tool.call.id` on both the parent's tool-call attribute and the child span, allowing join. 2. Child `execute_tool` spans carry their own token attributes (`gen_ai.usage.input_tokens` / `output_tokens`) rather than deferring entirely to the parent. 3. The collecto...",
    "decision_boundary": "The boundary is between **treating an agent span's status as authoritative for its children** versus **reconstructing completion from the child set**. The correct operational rule: an `invoke_agent` span is only *complete* if the set of `gen_ai.tool.call.id` values referenced in its attributes is a subset of the child `execute_tool` spans that have both `sta...",
    "operational_effect": "Once the phantom-success class is separated, the cost deficit resolves to a countable set of aborted-mid-tool runs, and the orchestrator can be made to retry exactly those tool calls (idempotent by `gen_ai.tool.call.id`) instead of trusting the parent's OK. The practical consequence is that agent token accounting becomes *reconcilable* rather than merely pla..."
  },
  "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": "aed03af6e51e61b38848b97262e7648a7b18bc796d86dfbf5af551bcc7add298",
    "verified_classes": [
      "OrphanedToolSpanError",
      "ToolCall",
      "AgentSpan"
    ],
    "verified_functions": [
      "reconcile_agent_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "OrphanedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
