{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-refuse-to-close-a-genai-span-when-a-tool-call-child-span-is-still-open-under-otel-semantic-conventions",
  "title": "Where must an instance refuse to close a GenAI span when a tool-call child span is still open under OTel semantic conventions",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.agent.*`) and treat span close as the authoritative record of a completed tool call or agent handoff. Does not apply to runtimes that buffer telemetry offline and reconcile spans in a separate collector-side join.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-a-genai-span-when-a-tool-call-child-span-is-still-open-under-otel-semantic-conventions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-a-genai-span-when-a-tool-call-child-span-is-still-open-under-otel-semantic-conventions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-refuse-to-close-a-genai-span-when-a-tool-call-child-span-is-still-open-under-otel-semantic-conventions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2045,
    "python_slice_tokens": 422,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A GenAI span is not a log line. It is a **lifetime-bounded state record** whose end timestamp and `status.code` are the only signals a downstream verifier (auditor agent, replay harness, or cost governor) can use to decide whether a tool call actually terminated. The failure mode here is not \"missing attributes.\" It is **premature span closure**: the parent ...",
    "what_was_observed": "A multi-agent handoff runtime (planner → executor → auditor) instrumented per GenAI semconv v1.29 emitted a `gen_ai.agent.invoke` span for the executor with `gen_ai.operation.name = \"invoke_agent\"`, a child `gen_ai.tool.call` span for an MCP `tools/call` to a filesystem server, and a grandchild span for the model completion that decided to make the call. Under load, the following trace appeared repeatedly: The second...",
    "condition_of_validity": "The invariant \"a closed parent span implies all its children have closed\" holds **only if** the span processor enforces it. The OTel SDK does not. Therefore any agent runtime that: 1. ends spans from `finally` blocks or async cleanup handlers that are not ordered after child completion, **and** 2. treats `status.code=OK` on a `gen_ai.agent.invoke` or `gen_ai...",
    "decision_boundary": "The boundary is **whether the span's end event is causally ordered after the side effect it claims to record.** Concretely: - If the tool call is synchronous and the span closes in the same call stack frame that returns the tool result → parent close is causally after completion. Safe. - If the tool call is dispatched to an async task, a thread pool, an MCP ...",
    "operational_effect": "When the invariant is violated and undetected: - **Handoff warrants propagate on false completion.** The auditor advances the baton on a `status.code=OK` that does not mean what it says. Downstream agents inherit a causal claim that is false. - **Retry logic double-executes side effects.** A cost governor seeing a 412ms `gen_ai.tool.call` under a 500ms budge..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "547d046970a13a98266a0e3fe806c2f55f4b5cc0c529ac22ce0c62ebee40cdd9",
    "verified_classes": [
      "PrematureSpanCloseError",
      "GenAISpan",
      "SpanRegistry"
    ],
    "verified_functions": [
      "verify_trace_ordering",
      "__init__",
      "start",
      "end",
      "end_or_mark_incomplete"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "PrematureSpanCloseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
