{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-emit-a-genai-agent-span-until-its-parent-tool-call-span-has-been-closed-by-the-transport-layer",
  "title": "Under what conditions must an instance refuse to emit a GenAI agent span until its parent tool-call span has been closed by the transport layer",
  "date_of_record": "2026 November 28",
  "scope": "Applies to instrumented LLM agent runtimes that emit OpenTelemetry spans following the GenAI semantic conventions (`gen_ai.*` attributes) and that nest tool-execution spans beneath an agent/chat span, where tool results are delivered asynchronously by an external transport (MCP server, A2A peer, or a queued executor). Does not apply to fully synchronous in-process tool calls where the child span closes within the parent's execution frame.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-genai-agent-span-until-its-parent-tool-call-span-has-been-closed-by-the-transport-layer.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-genai-agent-span-until-its-parent-tool-call-span-has-been-closed-by-the-transport-layer.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-emit-a-genai-agent-span-until-its-parent-tool-call-span-has-been-closed-by-the-transport-layer.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1825,
    "python_slice_tokens": 383,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model an agent turn as a parent span (`gen_ai.operation.name = \"chat\"` or `\"invoke_agent\"`) carrying `gen_ai.usage.input_tokens` / `gen_ai.usage.output_tokens`, with tool invocations represented either as span events or as child spans (`gen_ai.operation.name = \"execute_tool\"`) bearing `gen_ai.tool.name`, `gen_ai.tool.call.id`, ...",
    "what_was_observed": "In a runtime using an MCP stdio transport with a 30-second tool timeout, the agent loop emitted the parent `chat` span immediately after receiving the model's completion (which contained a `tool_calls` block), because the completion itself was the natural end-of-turn signal. The tool executor ran on a separate task and closed its `execute_tool` child span 200–4000 ms later. Under normal latency the parent had already...",
    "condition_of_validity": "The refusal-to-emit rule is valid — and required — precisely when all of the following hold: - The parent GenAI span's completion payload contains one or more `tool_calls` entries (i.e., `finish_reason == \"tool_calls\"` or equivalent). - Tool execution is dispatched to any executor whose completion is not guaranteed within the parent's synchronous frame (sepa...",
    "decision_boundary": "The runtime must make a binary decision at the moment the model completion is parsed: - **If the completion contains no tool calls:** close and export the parent span immediately. Token usage is final and no child can arrive later. - **If the completion contains tool calls:** mark the parent span **non-exportable** and transition it to a `PENDING_TOOL_RESOLU...",
    "operational_effect": "Enforcing the deferral converts a latency-dependent, intermittent orphaning bug into a bounded, deterministic wait. The cost is that the parent span's export is delayed by the slowest tool in the turn — bounded by the tool timeout. In the observed runtime this raised p99 trace-completion latency from 40 ms to 4.2 s for tool-bearing turns, but eliminated orph..."
  },
  "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": "d27fe20e7eb7757aa7b96c4e1da7f0d614f37b4201f42e34c1eaabde86a3da49",
    "verified_classes": [
      "SpanExportOrderError",
      "GenAISpan",
      "SpanTreeGuard"
    ],
    "verified_functions": [
      "__init__",
      "register_parent",
      "register_child",
      "close_child",
      "try_export_parent"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpanExportOrderError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
