{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-close-an-agent-span-when-opentelemetry-genai-tool-call-attributes-are-still-unresolved",
  "title": "In what scenarios must an instance refuse to close an agent span when OpenTelemetry GenAI tool-call attributes are still unresolved",
  "date_of_record": "2026 November 24",
  "scope": "Applies to LLM agent runtimes that emit OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`/`output_tokens`), where tool calls are delegated asynchronously. Does not cover synchronous single-shot completions with no tool delegation, nor non-OTel tracing backends.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-agent-span-when-opentelemetry-genai-tool-call-attributes-are-still-unresolved.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-agent-span-when-opentelemetry-genai-tool-call-attributes-are-still-unresolved.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-an-agent-span-when-opentelemetry-genai-tool-call-attributes-are-still-unresolved.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1701,
    "python_slice_tokens": 325,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **span completion** and **attribute finality**. The OpenTelemetry GenAI conventions treat a span as a closed record once `span.end()` is called: attributes are immutable thereafter, and the exporter flushes whatever it captured. But an agent's tool-call lifecycle is *not* aligned with its span lifecycle. A model emits ...",
    "what_was_observed": "A multi-tool agent loop emitted, per turn, a `chat` span whose child `execute_tool` span carried `gen_ai.tool.name`. When the tool backend (a vector-retrieval service) had a P99 latency exceeding the model client's own timeout, the runtime's `finally` block called `span.end()` on the parent `chat` span after the model turn returned but *before* the tool child span resolved. Observed consequences, in order: 1. The par...",
    "condition_of_validity": "The guardrail is only meaningful under a specific condition: the tool call is **asynchronous relative to the span that names it**, and the span carries attributes (`gen_ai.usage.*`, `gen_ai.tool.call.id`, `gen_ai.tool.name`) that are only fully known once the tool resolves. When the tool is synchronous and inline (result available before the model turn retur...",
    "decision_boundary": "The decision the runtime must make, per span, is binary and must be made *before* `end()` is reachable: - **Close now** only if every attribute the span is contractually required to carry is already set and no child tool span it names is still `IN_PROGRESS`. This is the synchronous case. - **Defer close** if any of: `gen_ai.tool.call.id` is set but the corre...",
    "operational_effect": "Enforcing deferred-close-with-sentinel changes three things operationally: 1. **Trace watermarks shift.** Parent spans now end at or after their children, restoring causal ordering. Cost aggregators that previously summed finalized spans now see a small tail of spans that carry `tool_result_unresolved`; these must be excluded from per-token cost sums and rep..."
  },
  "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": "cefc474d29e781cd94fd622c82c758e9388a6010cdd44f866c9fe3499adf7be0",
    "verified_classes": [
      "UnresolvedSpanError",
      "ToolCallState",
      "AgentSpan"
    ],
    "verified_functions": [
      "close_span",
      "run_agent_step"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnresolvedSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
