{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-span-orphaning-in-genai-observability-when-agent-tool-call-attribution-outlives-its-parent-span",
  "title": "What structural signals indicate span-orphaning in GenAI observability when agent tool-call attribution outlives its parent span",
  "date_of_record": "2026 November 27",
  "scope": "Applies to distributed-tracing-based GenAI observability pipelines where per-agent and per-tool-call cost/latency attribution is computed from span trees emitted by instrumented agent runtimes (OpenTelemetry-style), especially when tool calls execute asynchronously across process or network boundaries. Does not apply to single-process, fully synchronous instrumentation where span close is guaranteed by lexical scope, nor to billing reconciliation that uses provider-side usage records as ground truth.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-orphaning-in-genai-observability-when-agent-tool-call-attribution-outlives-its-parent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-orphaning-in-genai-observability-when-agent-tool-call-attribution-outlives-its-parent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-span-orphaning-in-genai-observability-when-agent-tool-call-attribution-outlives-its-parent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2168,
    "python_slice_tokens": 449,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing traces.\" It is **span orphaning**: a child tool-call span closes *after* its parent agent span has already been exported, finalized, and (often) aggregated into a cost rollup. The child carries a valid `parent_span_id` that no longer resolves to a live or even present parent in the collector's window, so the attribution engine mus...",
    "what_was_observed": "A recurring signature across instrumented agent deployments: - **Parent/child timestamp inversion.** Parent agent span `end_time` is *earlier* than a child tool-call span `start_time` for the same tool. This happens when the agent runtime emits the parent span at the point the LLM turn returns, but the tool call was dispatched to a worker pool and the worker's span is created *after* the parent already closed. The ch...",
    "condition_of_validity": "The invariant holds — and the guardrail is required — only under the conjunction: 1. **Asynchronous tool dispatch.** Tool calls may complete after the LLM turn that spawned them returns control to the agent loop. Synchronous tools (blocking call inside the turn) cannot orphan because the parent cannot close before the child. 2. **Parent-close-on-turn-return....",
    "decision_boundary": "The architectural choice is **where the parent span is allowed to close**, and it is a binary, not a tuning knob: - **Close parent at LLM-turn boundary** (default): minimizes parent-span wall-clock inflation, but requires the attribution engine to *re-open* or *amend* the parent aggregate when a late child arrives. Re-opening is only possible if the aggregat...",
    "operational_effect": "Without the barrier, the observable effect is a **stable, concurrency-proportional under-attribution of tool cost** that is invisible to every standard health signal (trace count, error rate, span count, dashboard greenness). The only detector is the ratio `child_attributed_cost / parent_attributed_cost`, which must be monitored as a first-class SLI and must..."
  },
  "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": "90d4afd3ea86ce9a601570c9d3aa300bce2fa99a666134a6ed293d9aefcfffcf",
    "verified_classes": [
      "SpanOrphanedError",
      "ParentAggregate",
      "AttributionEngine"
    ],
    "verified_functions": [
      "__init__",
      "open_parent",
      "close_parent",
      "close_child",
      "child_parent_ratio"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanOrphanedError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
