{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-the-orphaned-tool-call-span-in-opentelemetry-genai-agent-hierarchies",
  "title": "How does an instance detect the Orphaned Tool-Call Span in OpenTelemetry GenAI Agent Hierarchies",
  "date_of_record": "2026 November 16",
  "scope": "Applies to agents that emit `gen_ai.*` spans per the OpenTelemetry GenAI semantic conventions (agent → model → tool-call nesting) where tool execution is delegated to an out-of-process executor and token accounting is aggregated per agent. Does not apply to single-span synchronous inference calls, nor to deployments where tool execution is inlined within the parent model span's process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-orphaned-tool-call-span-in-opentelemetry-genai-agent-hierarchies.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-orphaned-tool-call-span-in-opentelemetry-genai-agent-hierarchies.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-the-orphaned-tool-call-span-in-opentelemetry-genai-agent-hierarchies.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1883,
    "python_slice_tokens": 465,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool call as a child span (`gen_ai.operation.name = \"execute_tool\"`) nested under the model-invocation span that requested it, with the model span carrying `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens` and the tool span carrying `gen_ai.tool.name` and `gen_ai.tool.call.id`. The non-obvious invariant is this...",
    "what_was_observed": "In a multi-agent deployment, per-agent token totals drifted upward by 15–40% relative to the sum of model-span tokens, while the global total stayed correct. The cause: when a tool span is reparented to the agent span, the tool's own token-bearing sub-spans (e.g., a nested `gen_ai.chat` call made by the tool) attach under the *tool* span, which now sits under the *agent* rather than under the *model*. Aggregation tha...",
    "condition_of_validity": "The invariant \"tool span parent = issuing model span\" holds only when: 1. The tool span is created from a context that carries the model span as its active span — i.e., the model invocation must explicitly pass its span context into the dispatch boundary, not rely on ambient context propagation. 2. The tool executor does not itself create a new root or agent...",
    "decision_boundary": "Detect the reparenting by comparing, for each tool span, the span id of its parent against the span id recorded in the model span's `gen_ai.tool.call.id` → issuing-span index. If the tool span's parent is the agent span rather than the model span, and the tool's output token count is non-zero, the span is misparented and its tokens must be attributed to the ...",
    "operational_effect": "Mis-detection has asymmetric cost. A false positive (flagging a fire-and-forget tool as misparented) inflates the reconciliation warning rate and trains operators to ignore the signal. A false negative (missing a reparented tool with model descendants) silently corrupts per-agent cost attribution — the failure mode that motivated this record, where per-agent..."
  },
  "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": "e2e5b0802b8f8c96dfed4befba4e9196dddcce54fa9a0e86af8a09522735b731",
    "verified_classes": [
      "MisparentedToolSpanError",
      "Span"
    ],
    "verified_functions": [
      "_has_model_descendants",
      "assert_tool_parent_invariant",
      "aggregate_agent_tokens"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "MisparentedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
