{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-close-a-genai-agent-turn-span-when-tool-call-child-spans-report-gen-ai-tool-call-id-values-that-do-not-re",
  "title": "In what scenarios must an instance refuse to close a GenAI agent-turn span when tool-call child spans report `gen_ai.tool.call.id` values that do not reconcile with the parent's `gen_ai.agent.turn.tool_calls`",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans for agent turns and their tool-call children, where the parent turn span is closed after the tool results are re-ingested into the model context. Does not apply to single-shot completion tracing with no tool loop, nor to runtimes that emit tool calls as span *events* rather than child spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-agent-turn-span-when-tool-call-child-spans-report-gen-ai-tool-call-id-values-that-do-not-re.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-agent-turn-span-when-tool-call-child-spans-report-gen-ai-tool-call-id-values-that-do-not-re.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-close-a-genai-agent-turn-span-when-tool-call-child-spans-report-gen-ai-tool-call-id-values-that-do-not-re.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1980,
    "python_slice_tokens": 287,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a tool call failed.\" A failed tool call is a normal, well-formed trace: the child span ends with `ERROR`, the parent turn records a `gen_ai.agent.turn.tool_calls` count that includes it, and the model sees a tool-result message describing the error. That is coherent telemetry. The boundary case is subtler: **the set of tool-call identifie...",
    "what_was_observed": "A planner agent emitted a single assistant message containing four parallel tool calls (`call_a`, `call_b`, `call_c`, `call_d`). The runtime wrote the parent turn span's `gen_ai.agent.turn.tool_calls = 4` synchronously from the parsed model response, then dispatched the four executions to an async executor. During dispatch: - `call_b` was deduplicated against an identical call already in-flight from the prior turn (a...",
    "condition_of_validity": "The refusal-to-close rule is valid — and required — precisely under these conditions, all of which must hold: 1. The parent agent-turn span declares a tool-call count or identity list (`gen_ai.agent.turn.tool_calls`, or a custom `tool_call_ids` array attribute) **at a time strictly before** all child tool spans have ended. 2. Tool execution is fanned out con...",
    "decision_boundary": "At parent-span close, the runtime must compute: - `declared = {id : id ∈ parent.gen_ai.agent.turn.tool_call_ids}` (or the count, if only a count is available) - `observed = {child.gen_ai.tool.call.id : child linked to parent}` and branch: - `observed ⊆ declared` **and** `declared \\ observed = ∅` → close normally, `status = OK`. - `observed ⊆ declared` **and*...",
    "operational_effect": "Enforcing the boundary converts a silent telemetry defect into a loud, structured one at the exact span where the divergence originates, before it propagates to eval and cost pipelines. The concrete effects: - **Cost attribution stops double-counting.** Deduplicated calls (`call_b`) are marked `unexecuted/deduplicated` rather than vanishing, so a cost job th..."
  },
  "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": "26c2415e57eb219593936a6cf4bb894fd3585d34558d782e83f79777d3896fcc",
    "verified_classes": [
      "ToolCallReconciliationError",
      "TurnSpan"
    ],
    "verified_functions": [
      "close_agent_turn_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ToolCallReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
