{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reconcile-orphaned-genai-tool-call-spans-before-exporting-them-under-opentelemetry-semantic-conventions",
  "title": "In what scenarios must an instance reconcile orphaned GenAI tool-call spans before exporting them under OpenTelemetry semantic conventions",
  "date_of_record": "2026 November 26",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans using the `gen_ai.*` semantic conventions (specifically `gen_ai.operation.name`, `gen_ai.tool.call.id`, and parent-child linkage between an `execute_tool` span and its enclosing `chat` span) and that batch/spool spans for asynchronous export. Does not apply to synchronous, single-process tracing where the tool span is guaranteed to close before the parent chat span, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-orphaned-genai-tool-call-spans-before-exporting-them-under-opentelemetry-semantic-conventions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-orphaned-genai-tool-call-spans-before-exporting-them-under-opentelemetry-semantic-conventions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reconcile-orphaned-genai-tool-call-spans-before-exporting-them-under-opentelemetry-semantic-conventions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1962,
    "python_slice_tokens": 334,
    "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\"`) whose parent is the `chat` span that requested it. The convention assumes a strict nesting: the chat span opens, emits one or more tool-call requests, the tool spans open and close, and then the chat span closes with `gen_ai.usage.*` totals. This ass...",
    "what_was_observed": "A retrieval-augmented agent loop emits one `chat` span per model turn and, within that turn, fans out three parallel `execute_tool` spans (vector search, SQL lookup, web fetch). The web fetch has a 30s timeout; the chat span has a 10s deadline inherited from the request budget. Trace: 1. `t=0ms` — `chat` span opens, `span_id=A`. 2. `t=180ms` — model returns a tool-call block; runtime opens three `execute_tool` spans ...",
    "condition_of_validity": "The reconciliation guardrail is only *required* — and only *correct* — under the conjunction: - Tool spans can outlive their parent chat span (concurrent dispatch, deadline < tool timeout, or cross-checkpoint deferral), **and** - spans are exported in batches or spooled to disk rather than streamed synchronously within a single trace context, **and** - a dow...",
    "decision_boundary": "At span-close time, the runtime must decide whether to export the tool span directly or route it through reconciliation. The boundary condition is a single predicate evaluated against the local span registry: - If `parent_span_id` is present in the *unexported* set (parent has not yet been flushed) → export normally; ordering within the batch is irrelevant b...",
    "operational_effect": "Applying source-side reconciliation converts a class of silent structural loss into an explicit, countable signal. In the fan-out trace above, the web-fetch timeout now exports re-parented to a synthetic `gen_ai.agent.invocation` span that spans the entire agent run, carrying `gen_ai.tool.orphan_reason = \"parent_premature_export\"`. The operator sees the time..."
  },
  "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": "e9650d127129eb46a3c8b903b586804b8d3280d6a5ec89a4e32db834f7b626e1",
    "verified_classes": [
      "OrphanedToolSpanError",
      "ParentState",
      "SpanRegistry",
      "ToolSpan"
    ],
    "verified_functions": [
      "reconcile_before_export",
      "state_of"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "OrphanedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
