{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-close-an-llm-span-before-its-downstream-tool-execution-trace-has-been-durably-acknowledged",
  "title": "In what scenarios must an instance refuse to close an LLM span before its downstream tool-execution trace has been durably acknowledged",
  "date_of_record": "2026 November 20",
  "scope": "Applies to any instrumented agent runtime where a single LLM inference span (the \"parent\" span emitted by an observability SDK around a model call) is correlated to one or more downstream tool-execution traces (child spans emitted by a separate executor, sidecar, or remote tool host) via a propagated trace/span identifier. Does not apply to purely in-process tool calls whose child spans are emitted synchronously by the same tracer and flushed in the same batch as the parent.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-llm-span-before-its-downstream-tool-execution-trace-has-been-durably-acknowledged.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-llm-span-before-its-downstream-tool-execution-trace-has-been-durably-acknowledged.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-llm-span-before-its-downstream-tool-execution-trace-has-been-durably-acknowledged.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2114,
    "python_slice_tokens": 386,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"missing traces.\" It is **premature span finalization under trace-context propagation lag**. The LLM span and the tool-execution trace are produced by two different clocks and two different flush boundaries. The parent span is closed by the inference loop the instant the model returns a `tool_use` block and the SDK's `end()` is called...",
    "what_was_observed": "A tool-using agent (model → `search_docs` tool → model) was instrumented with an OpenTelemetry-style tracer. The inference wrapper opened a span `llm.call`, set attributes, called the model, received a tool-call block, and immediately called `span.end()`. The orchestrator then dispatched `search_docs`, whose executor opened a child span with `parent_span_id = llm.call`'s span id. Under normal load, ~99.2% of `search_...",
    "condition_of_validity": "The guardrail holds — and the refusal-to-close rule is required — exactly when all three of the following are true: - **C1 (asynchrony):** The tool-execution trace is emitted by a process, sidecar, or host that is not the span-closing process, so its registration write is not ordered by program order relative to `span.end()`. - **C2 (id reuse or id non-uniqu...",
    "decision_boundary": "The decision is: **when may `span.end()` be called on the parent LLM span?** - **Close immediately** only if the model returned a terminal response (no tool-call block) — there are no children to correlate. - **Close immediately** if the tool call is dispatched *and* the dispatcher has synchronously obtained a durable registration acknowledgment (the child s...",
    "operational_effect": "Enforcing the invariant changes three things: 1. **Trace completeness becomes a function of registration acks, not flush timing.** Correlation loss under burst dropped from 39% to 0.4% in the observed workload (residual 0.4% were genuine executor crashes, correctly surfaced as `correlation_state = child_failed`, not silently demoted). 2. **False edges disapp..."
  },
  "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": "5129a622d5fc0d238895e4493a0505f02d65e19d7dd626968f6deaa78381804c",
    "verified_classes": [
      "CorrelationInvariantError",
      "CorrelationState",
      "ParentSpan",
      "SpanRegistry"
    ],
    "verified_functions": [
      "emit_llm_span",
      "__init__",
      "open_parent",
      "register_child",
      "finalize_parent"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CorrelationInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "time"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
