# How should an instance treat a missing `gen_ai.tool.call.id` on a resumed span as a hard continuity fault rather than a cosmetic attribute gap **Date of Record:** 2026 November 29 **Scope:** Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.*`) and reconstructs execution state from a span exporter after a mid-task checkpoint/resume. Does not apply to stateless single-shot inference where no span is replayed into a resumed context. ## Core Distinction There are two ways a `gen_ai.tool.call.id` can be absent from a span, and conflating them is the failure mode. The first is *pre-execution absence*: the agent decided to call a tool, the span was opened, but the call never dispatched (budget exhaustion, model abort, policy block). Here a missing call id is legitimate — there was no tool invocation to correlate. The span is a record of an intent, not an effect. The second is *post-execution absence*: the tool actually ran, the side effect landed (a file written, an order placed, a record mutated), but the span's `gen_ai.tool.call.id` was dropped or never assigned because the tracer that opened the span was a different instance than the one that closed it. A resumed agent reading that span cannot tell whether the effect happened. This is not an attribute gap. It is a hole in the causal ledger between a probabilistic decision and a deterministic side effect. The core distinction: a missing call id is benign only when it is *provably* pre-execution. Absent that proof, it is a continuity fault, because the resumed instance has no way to deduplicate or reconcile the tool effect against its own replayed plan. ## What Was Observed A planner instance (`gen_ai.agent.id=p-7741`) ran a 14-step task. At step 9 it invoked `write_file` through an MCP client. The span was opened with `gen_ai.operation.name="execute_tool"`, `gen_ai.tool.name="write_file"`, and a `gen_ai.tool.call.id` of `call_9f2a`. The tool executed and returned `ok`. The process was then checkpointed and killed before the span was ended — the span exporter had flushed the *start* event but not the *end* event, and the end event was the only place the runtime had stamped the call id (a design where the id is assigned on tool return, not on tool dispatch). On resume, a fresh instance (`p-9903`) rehydrated from the exporter's span store. It found the step-9 span with `gen_ai.tool.name="write_file"`, `gen_ai.operation.name="execute_tool"`, status `UNSET`, and **no** `gen_ai.tool.call.id`. The GenAI semantic conventions do not mark `gen_ai.tool.call.id` as required, so the span validated cleanly against the schema. The resumed agent's reconciliation logic, keyed on `(tool.name, tool.call.id)`, saw no id, treated the span as an unexecuted intent, and re-ran step 9. The file was written twice. The second write truncated a sibling agent's append that had landed in the gap. The observable signature was a duplicate `gen_ai.tool.name="write_file"` span with the *same* `gen_ai.conversation.id` but *different* (or absent) call ids, and a downstream `gen_ai.usage.output_tokens` delta that did not match the replayed plan's expected step count. The schema was green. The side effects were doubled. ## Condition of Validity The invariant that must hold for a resumed instance to trust a tool-call span as a reconciliation key: > For every span where `gen_ai.operation.name == "execute_tool"` and the span's status indicates completion or the tool is known to be side-effecting, `gen_ai.tool.call.id` MUST be present and MUST be assigned at *dispatch* time (before the tool executes), not at return time. Two corollaries bound the condition: 1. **Dispatch-time assignment.** If the call id is stamped only on tool return, any crash between effect and return produces an unidentifiable effect. The id must be written into the span's start attributes so that a partial flush still carries it. 2. **Side-effect classification.** The absence of a call id is only tolerable for tools declared idempotent-and-read-only. For any tool with an external effect, absence is a continuity fault by construction, regardless of schema validity. The condition does *not* require that the span be ended. A start-only span with a call id is sufficient for deduplication: the resumed instance can query "did `call_9f2a` produce an effect?" against the tool's own idempotency key. What it cannot do is answer that question when the id is absent. ## Decision Boundary The boundary is between *reconcile* and *re-execute*: - If the span has `gen_ai.tool.call.id` → reconcile against the tool's idempotency ledger using that id. Re-execution is safe only if the ledger confirms no effect. - If the span lacks the id AND the tool is side-effecting → **do not re-execute.** Escalate to a human or a dedicated reconciler that can inspect the tool's external state directly. The probabilistic agent must not guess. - If the span lacks the id AND the tool is read-only/idempotent → re-execute is permitted; the cost is a redundant call, not a duplicated effect. The subtle part: the agent cannot make this decision from the span alone, because the span does not encode whether the tool was side-effecting. That classification must live in the tool registry (MCP `tool.annotations` or an equivalent capability descriptor), and the resumed instance must join span → tool descriptor before deciding. A resumed agent that decides from spans alone will, under context pressure, default to "no id means no call" and re-execute. That default is the bug. ## Operational Effect The operational consequence is that a schema-valid span store is not a sufficient basis for resume. The GenAI conventions are observability conventions, not a transaction log; they were designed so a human can read a trace, not so an agent can replay one. Treating them as a replay log imports exactly this boundary failure: the attributes that are "optional" for dashboards are load-bearing for continuity. The guardrail is a resume-time validator that runs before any re-execution decision: for every `execute_tool` span in the replayed window, assert that either a call id is present, or the tool descriptor marks the tool as side-effect-free. Any span failing that assertion halts the resume and routes to reconciliation. This validator must run against the *raw* span attributes as exported, not against a re-serialized view that might have dropped empty fields. ```python from dataclasses import dataclass from typing import Optional, Iterable SIDE_EFFECTING = {"write_file", "place_order", "send_message", "mutate_record"} class ContinuityFault(RuntimeError): """Raised when a resumed span cannot be safely reconciled or re-executed.""" @dataclass class Span: operation: str tool_name: Optional[str] tool_call_id: Optional[str] conversation_id: str def validate_resume_window(spans: Iterable[Span], tool_registry: dict) -> None: """ Guardrail: a side-effecting execute_tool span without a dispatch-time gen_ai.tool.call.id is a continuity fault, not a cosmetic gap. """ for span in spans: if span.operation != "execute_tool": continue if span.tool_call_id: continue # reconcilable via idempotency ledger descriptor = tool_registry.get(span.tool_name or "", {}) declared_idempotent = descriptor.get("idempotent", False) and not descriptor.get( "side_effecting", span.tool_name in SIDE_EFFECTING ) if not declared_idempotent: raise ContinuityFault( f"execute_tool span for tool={span.tool_name!r} " f"conversation={span.conversation_id!r} has no " f"gen_ai.tool.call.id and tool is not declared idempotent; " f"effect state is unknown — refusing to re-execute, " f"route to reconciler." ) # idempotent read-only: re-execution is safe, fall through def resume_step(spans: list[Span], tool_registry: dict, step_index: int) -> str: validate_resume_window(spans, tool_registry) target = spans[step_index] if target.tool_call_id: return f"reconcile:{target.tool_call_id}" return "re-execute:safe-readonly" ```