{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-a-genai-tool-call-span-as-non-terminal-when-the-agent-loop-has-already-advanced",
  "title": "Under what conditions must an instance treat a GenAI tool-call span as non-terminal when the agent loop has already advanced",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic conventions (`gen_ai.*`) for LLM turns and tool calls, where a single logical tool invocation may be re-entered, retried, or abandoned by the reasoning loop. Does not apply to single-shot inference telemetry or to tracing systems where the agent loop and the span lifecycle are owned by the same scheduler thread.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-tool-call-span-as-non-terminal-when-the-agent-loop-has-already-advanced.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-tool-call-span-as-non-terminal-when-the-agent-loop-has-already-advanced.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-a-genai-tool-call-span-as-non-terminal-when-the-agent-loop-has-already-advanced.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2081,
    "python_slice_tokens": 432,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool call as a span with a start and an end, mirroring the request/response shape of ordinary RPC instrumentation. But an agent loop is not an RPC client. The reasoning loop can *decide* a tool call is obsolete — because a later turn produced a better answer, because a retry superseded it, because the model emitted a co...",
    "what_was_observed": "A three-tool agent was instrumented with `gen_ai.operation.name = \"execute_tool\"` spans, each carrying `gen_ai.tool.name`, `gen_ai.tool.call.id`, and a parent span for the enclosing `gen_ai.operation.name = \"chat\"` turn. The loop ran with a per-turn timeout and a \"best-so-far\" policy: if a tool call exceeded its budget, the loop emitted a replacement call and adopted whichever result arrived first. The failure trace:...",
    "condition_of_validity": "The invariant holds — and the failure is real — only under the conjunction of three conditions: - **The loop can advance without the executor returning.** If the runtime blocks on every tool call until the executor resolves (synchronous, no supersession), span-close and execution-end coincide and the boundary is invisible. - **The executor outlives the loop'...",
    "decision_boundary": "The instance must draw the boundary between **loop state** and **span state** explicitly, and must not let the former close the latter. Concretely, a tool-call span may be closed by the loop only when one of the following is true: - The executor has returned a terminal result (success or error), and the span records it. - The executor has been *cancelled and...",
    "operational_effect": "An instance that respects this boundary gains three properties it otherwise lacks. Its traces are *replayable*: an auditor can distinguish \"the model ignored a good result\" from \"the runtime dropped a late result,\" which are different bugs with different fixes. Its error metrics are *honest*: abandoned calls surface as errors at the turn level instead of van..."
  },
  "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": "1c8a52f1347351f328cedd67745807a16a328e1ec135954e7a2ba19e711dbd5e",
    "verified_classes": [
      "SpanLifecycleViolation",
      "ExecutorState",
      "ToolCallSpan"
    ],
    "verified_functions": [
      "close_span_on_loop_advance",
      "resolve_late_result"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpanLifecycleViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
