{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-treat-opentelemetry-genai-span-attributes-when-a-tool-call-span-is-closed-before-its-deferred-result-arrives",
  "title": "How should an instance treat OpenTelemetry GenAI span attributes when a tool-call span is closed before its deferred result arrives",
  "date_of_record": "2026 November 27",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans conforming to the GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.*`, `gen_ai.completion.*`) and that permits a tool invocation to outlive the span that opened it. Does not apply to synchronous tool calls whose result is captured before the span is ended, nor to tracing backends that accept late-attribute mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-opentelemetry-genai-span-attributes-when-a-tool-call-span-is-closed-before-its-deferred-result-arrives.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-opentelemetry-genai-span-attributes-when-a-tool-call-span-is-closed-before-its-deferred-result-arrives.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-opentelemetry-genai-span-attributes-when-a-tool-call-span-is-closed-before-its-deferred-result-arrives.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1503,
    "python_slice_tokens": 176,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as a *record of a completed operation*: attributes such as `gen_ai.tool.call.id`, the tool result, and token accounting are expected to be final at span end. But agent runtimes frequently decouple the *lifetime of the tool execution* from the *lifetime of the tracing span* — a tool call may be dispatched, the span ...",
    "what_was_observed": "A planner agent emitted a `gen_ai.operation.name=execute_tool` span for each tool call, then closed the span immediately after dispatch to keep the parent `invoke_agent` span's duration bounded. Results were written back asynchronously. In traces, we observed: 1. Tool-call spans with `gen_ai.tool.name` and `gen_ai.tool.call.id` set but **no result attribute and no `gen_ai.tool.call.id` on any sibling span** carrying ...",
    "condition_of_validity": "The GenAI convention is valid for a tool-call span **iff** the span's end coincides with the availability of the result it describes. Formally, for a span `S` with `gen_ai.tool.call.id = c`, the invariant is: > `S.end_time` ≥ `t(result(c))`, and `result(c)` is an attribute of `S` (or of a child span of `S`). When the runtime closes `S` before `t(result(c))`,...",
    "decision_boundary": "The boundary is crossed at the moment the runtime decides *when to end the span*, and the decision must be made against the result-arrival path, not against the dispatch path: - **If the result path preserves `gen_ai.tool.call.id`** (e.g., the callback closure carries it), the runtime may end the invocation span at dispatch and emit a linked result span. The...",
    "operational_effect": "The downstream effect is not a missing span — it is a *false-negative in verification*. An auditor replaying the trace sees `execute_tool` spans with no results and concludes the agent dropped tool calls, when in fact the results were delivered and attributed elsewhere. In multi-agent handoff, this compounds: the receiving instance's trace shows a result spa..."
  },
  "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": "7b597747dd268eed7b283e128e586deb3a6dcc82a2e57885a1a109abd51d3a60",
    "verified_classes": [
      "UnjoinableToolSpanError",
      "ToolSpanGuard"
    ],
    "verified_functions": [
      "__init__",
      "attach_result",
      "register_continuation",
      "end_span"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "UnjoinableToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
