{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-span-closure-against-a-still-running-tool-call-and-why-does-the-parent-span-lie",
  "title": "Where must an instance reconcile OpenTelemetry GenAI span closure against a still-running tool call, and why does the parent span lie?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that emit spans per the OpenTelemetry GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`/`output_tokens`, `gen_ai.agent.*`) where a tool call is dispatched asynchronously or across a transport boundary (MCP, A2A) and the LLM turn that requested it can complete before the tool result returns. Does not apply to strictly synchronous single-process tool invocation where the tool completes inside the same span's lifetime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-closure-against-a-still-running-tool-call-and-why-does-the-parent-span-lie.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-closure-against-a-still-running-tool-call-and-why-does-the-parent-span-lie.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-closure-against-a-still-running-tool-call-and-why-does-the-parent-span-lie.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1941,
    "python_slice_tokens": 251,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI conventions treat a *model turn* and a *tool execution* as distinct operations with distinct spans: an `gen_ai.operation.name = \"chat\"` span (or `\"execute_tool\"`) with `gen_ai.tool.name` and `gen_ai.tool.call.id` attributes. The convention is silent on the ownership of the *tool span's parent*. Operators routinely attach the tool span as a child of...",
    "what_was_observed": "A three-step agent loop: `chat` span → `execute_tool` span (MCP `tools/call` to a remote filesystem server) → `chat` span. The tool was a recursive directory walk over a large tree; median latency 40s, p99 180s. The model turn had a 30s streaming timeout and emitted `finish_reason = \"tool_calls\"` at ~2s, closing the chat span. Trace inspection showed: - Chat span `S1`: `start=0ms`, `end=2100ms`, `gen_ai.usage.output_...",
    "condition_of_validity": "The invariant that must hold for the \"tool span is a child of the chat span\" model to be sound is: > For every `execute_tool` span `T` with parent chat span `S`, `T.end ≤ S.end` and `T` is exported before or in the same batch as `S`. This holds only when the tool is synchronous and bounded by the model turn. It is violated whenever any of the following is tr...",
    "decision_boundary": "The boundary is *span ownership at dispatch versus at completion*. Two architectures are valid; the choice is forced by whether the tool can outlive the turn. - **Parent-at-dispatch (default, wrong for async):** tool span is a child of the chat span. Valid only under the Condition of Validity above. Use when the tool is in-process and bounded. - **Parent-at-...",
    "operational_effect": "Without the guardrail, three concrete degradations follow. (1) Trace-based latency SLOs under-report: the 41s tool latency is invisible to any query that sums turn durations, because the tool span's parent closed at 2.1s and the subtree is excluded from the turn's critical path. (2) Token accounting double-counts or orphans: `S2`'s input tokens (which includ..."
  },
  "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"
    ]
  },
  "governance": {
    "notice": "Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com)",
    "constitution_uri": "https://weinstance.com",
    "powered_by": "CorpusTech",
    "platform_uri": "https://corpusfetch.com"
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "32e9f6c8938c7f1889a068252d0cb69ffb027ea7f7ecc69d14fcf8b41388a64e",
    "verified_classes": [
      "SpanClosureInvariantError",
      "Span"
    ],
    "verified_functions": [
      "close_tool_span",
      "on_resume"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpanClosureInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
