{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-genai-semantic-convention-spans-when-a-tool-call-child-span-outlives-its-parent-agent-span",
  "title": "How should an instance reconcile GenAI semantic-convention spans when a tool-call child span outlives its parent agent span",
  "date_of_record": "2026 November 20",
  "scope": "Applies to any agent runtime that emits OpenTelemetry spans under the `gen_ai.*` semantic conventions (agent invocation spans, tool-call spans, and token-usage attributes) and that can emit a tool-call child span whose completion timestamp exceeds its parent agent invocation span. Does not apply to single-shot, non-tool-using LLM calls, nor to runtimes that hard-cancel child spans synchronously with the parent.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-genai-semantic-convention-spans-when-a-tool-call-child-span-outlives-its-parent-agent-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-genai-semantic-convention-spans-when-a-tool-call-child-span-outlives-its-parent-agent-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-genai-semantic-convention-spans-when-a-tool-call-child-span-outlives-its-parent-agent-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1664,
    "python_slice_tokens": 155,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token accounting and tool-call identity as *attributes on spans*, not as independent events. A tool-call span (`gen_ai.operation.name = \"execute_tool\"`) is modeled as a child of the agent invocation span (`gen_ai.operation.name = \"invoke_agent\"`), and usage is recorded via `gen_ai.usage.input_tokens` / `gen_ai.usage.outpu...",
    "what_was_observed": "A three-tool agent turn (search → fetch → summarize) on a runtime that closes the agent span at the model's final `stop_reason = \"tool_use\"` boundary rather than at tool completion: 1. `invoke_agent` span opens at t=0, `gen_ai.usage.input_tokens=1840`, `output_tokens=212` recorded on the first generation child. 2. Generation child emits `tool_use` for `search`; model returns. Runtime marks the turn complete, closes `...",
    "condition_of_validity": "The containment invariant holds — and the convention's accounting is sound — only when **all three** of the following are true: - The runtime closes the parent agent span *after* all synchronous tool calls it spawned have closed, **or** the runtime explicitly marks the turn as \"tool-pending\" and defers parent closure. - The trace backend does not re-parent l...",
    "decision_boundary": "The decision is whether to (a) enforce containment by deferring parent closure until tool completion, or (b) break containment explicitly and make the break legible to consumers. The boundary condition: - **Enforce containment (a)** when the tool call is bounded and short (< the parent turn's own deadline) and when the trace is consumed by subtree-summing ag...",
    "operational_effect": "Under (a), per-turn latency is inflated by tool wall-clock; token-per-second metrics computed as `output_tokens / span_duration` are systematically depressed for tool-heavy turns. Under (b), subtree-summed usage is correct only if consumers join by `gen_ai.tool.call.id`; any consumer that sums by parent/child will under- or over-count depending on ingestion ..."
  },
  "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": "54ec8191e26b655e6f8c9e2ee02e3a5627243d02a14cc44309577f50d4559898",
    "verified_classes": [
      "OrphanedToolSpanError"
    ],
    "verified_functions": [
      "close_agent_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "OrphanedToolSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
