# In what scenarios must an instance treat tool-call latency as a semantic signal rather than a performance metric, and how does retry-storm amplification corrupt trace convention compliance **Date of Record:** 2026 November 29 **Scope:** Applies to single- and multi-agent systems where tool calls are instrumented with OpenTelemetry-style spans and where retry logic is agent-controlled (not transport-controlled). Does not apply to pure transport-layer retries (TCP, gRPC deadlines) that never surface as distinct agent reasoning steps, nor to batch/offline inference where wall-clock latency is decoupled from decision cadence. ## Core Distinction The conventional observability stance treats tool-call latency as a *performance* dimension: a scalar to be histogrammed, alerted on at p99, and otherwise ignored by the reasoning loop. The distinction that matters operationally is that **latency is also a semantic signal about the tool's internal state**, and the agent's retry policy is a *consumer* of that signal. When an agent retries on a timeout, it is making a claim: "the prior call did not complete, therefore the effect did not occur." That claim is frequently false. A slow tool call is often a *committed* tool call — the write landed, the side effect fired, the remote agent advanced its state — and the timeout fired only on the response leg. The boundary condition is this: **an agent that treats latency as a pure performance metric will retry on timeout without an idempotency check, and the resulting retry storm will emit traces that are individually well-formed but collectively violate the semantic conventions they claim to follow.** The trace looks compliant (correct span names, correct parent-child nesting, correct attribute keys) while the *meaning* of the spans is corrupted: a single logical operation is represented as N sibling spans with no `retry_of` linkage, and downstream trace consumers — including other agents — reconstruct a false causal history. ## What Was Observed A retrieval-augmented agent issuing `search_index` calls against a vector store with a 2s client-side deadline. The store's p50 latency was 180ms, but during index compaction windows (roughly every 40 minutes, lasting ~90s) latency spiked to 3–6s. The agent's tool wrapper had a naive retry: on `DeadlineExceeded`, retry up to 4 times with 250ms fixed backoff. During a compaction window the following trace pattern emerged, repeated across concurrent agent instances: - Span `search_index` (attempt 1) — status `ERROR`, `error.type=DeadlineExceeded`, duration 2001ms. - Span `search_index` (attempt 2) — status `ERROR`, `DeadlineExceeded`, duration 2003ms. - Span `search_index` (attempt 3) — status `OK`, duration 4100ms, attributes `result.count=12`. Three observations that broke the naive reading: 1. **The store logged three successful query executions**, not one. The client deadline aborted the *response read*, not the server-side query. Attempts 1 and 2 had committed their reads; their results were discarded. 2. **The emitted spans were siblings under the same parent** with identical `name` and no distinguishing attribute. The OpenTelemetry semantic conventions for retries expect a `retry.count` (or equivalent) attribute and, for the `OK` span, a link back to the failed attempts. None was emitted. A trace consumer saw three independent `search_index` calls, one of which succeeded — a false model of the operation. 3. **The retry storm amplified under concurrency.** Ten agent instances hitting the same compaction window each emitted 4 attempts = 40 spans for ~10 logical operations, and the load *extended* the compaction window by ~35s, which extended the storm. The storm was self-sustaining: retries caused the latency that triggered retries. The semantic-convention violation is the non-obvious part. The spans passed schema validation. They failed *semantic* validation: they asserted a causal structure (three independent calls) that did not match the operational reality (one logical call, three committed executions, one retained result). ## Condition of Validity The failure requires the conjunction of four conditions. Remove any one and the invariant holds: 1. **The tool has a committed side effect or a committed read whose result is discarded on abort.** Pure-compute tools with no external state are immune; the retry is genuinely a re-execution. 2. **The client deadline is shorter than the tool's tail latency**, so timeouts occur on the response leg rather than the request leg. If the deadline is generous relative to tail latency, the abort never fires post-commit. 3. **The retry policy is agent-controlled and blind to idempotency.** A transport-layer retry with an idempotency key is safe; an agent-level retry that re-invokes the tool without a dedup token is not. 4. **The trace emission does not link retries to their origin.** If the wrapper emits a `retry_of` span link or a `retry.count` attribute, the trace is semantically recoverable even if the retries occurred. The invariant that the failure violates: **a trace must represent logical operations, not physical attempts, at the level where causal reasoning consumes it.** Physical attempts belong in span events or linked child spans; the logical operation is the unit of causality. ## Decision Boundary The agent must decide, per tool call, whether latency is *informational* (safe to retry) or *semantic* (retry requires idempotency proof). The boundary is drawn by a capability declaration on the tool, not by runtime inference — runtime inference of "did the side effect land" is exactly the unreliable step. - **If the tool declares `idempotent=true` with a client-supplied `dedup_key`**: retry freely; latency is performance-only. Emit retries as span *events* on the single logical span. - **If the tool declares `idempotent=false` or omits the declaration**: a timeout is *ambiguous* — treat it as `UNKNOWN_COMMIT`. Do not retry. Escalate to a reconciliation step that queries the tool's state (e.g., a `get_status(dedup_key)` call) before deciding. Emit the logical span with `commit.status=UNKNOWN` and a child span for the reconciliation. - **If the tool declares `idempotent=true` but the wrapper cannot supply a `dedup_key`**: downgrade to the non-idempotent path. A declaration without an enforcement mechanism is a lie in the capability schema. The retry-storm guard is a separate boundary: **retries must be budgeted globally, not per-call.** A per-call retry budget of 4 under 10 concurrent instances is a 40x amplification budget. The correct bound is a token-bucket shared across the agent's tool-call surface, drained by every retry, so that a compaction window cannot be extended by the retries it induces. ## Operational Effect Downstream effects of getting this boundary wrong, in order of latency to detection: - **Immediate:** trace consumers (auditor agents, replay verifiers) reconstruct a false causal graph. A verifier that replays the trace sees three `search_index` calls and may conclude the agent queried three times — inflating its estimate of the agent's information-gathering and potentially flagging a "redundant query" policy violation that never occurred. - **Short-horizon:** the retry storm extends the latency window that triggered it. The system enters a positive-feedback regime where p99 latency is a function of retry volume, and the observability dashboard — which is measuring the *symptom* — reports the storm as a tool-health problem rather than an agent-policy problem. - **Long-horizon:** semantic convention drift. Once traces routinely omit `retry.count` and `retry_of`, the convention is effectively dead in that deployment, and any new consumer that *does* rely on it will misparse. The convention's value is entirely in its uniform application; a partially-applied convention is worse than none, because it produces confident wrong answers. The guardrail that bounds the failure is the conjunction of (a) a capability declaration with an enforced dedup key, (b) a global retry token-bucket, and (c) a trace emission rule that collapses physical attempts into span events on a single logical span. The following reference implementation encodes the decision boundary and raises on the ambiguous-commit path rather than silently retrying. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class AmbiguousCommitError(RuntimeError): """Raised when a non-idempotent tool times out and commit status is unknown. Retrying in this state risks duplicate side effects and corrupts trace semantics by emitting sibling spans for a single logical operation. """ class CommitStatus(Enum): COMMITTED = "committed" NOT_COMMITTED = "not_committed" UNKNOWN = "unknown" @dataclass class ToolCapability: name: str idempotent: bool supports_dedup_key: bool @dataclass class RetryBudget: """Global token bucket; retries drain from a shared pool, not per-call.""" tokens: int refill_per_call: int = 1 def try_consume(self) -> bool: if self.tokens <= 0: return False self.tokens -= 1 return True @dataclass class LogicalSpan: name: str attempts: list = field(default_factory=list) commit_status: CommitStatus = CommitStatus.UNKNOWN def record_attempt(self, duration_ms: int, error: Optional[str]) -> None: # Physical attempts are span EVENTS, not sibling spans. self.attempts.append({"duration_ms": duration_ms, "error": error}) def invoke_tool( cap: ToolCapability, budget: RetryBudget, call_fn, dedup_key: Optional[str], timeout_ms: int, ) -> LogicalSpan: span = LogicalSpan(name=cap.name) while True: try: result = call_fn(timeout_ms=timeout_ms, dedup_key=dedup_key) span.record_attempt(duration_ms=timeout_ms, error=None) span.commit_status = CommitStatus.COMMITTED return span except TimeoutError as exc: span.record_attempt(duration_ms=timeout_ms, error="DeadlineExceeded") # Idempotency check: a declaration without enforcement is a lie. safe_to_retry = ( cap.idempotent and cap.supports_dedup_key and dedup_key is not None ) if not safe_to_retry: span.commit_status = CommitStatus.UNKNOWN raise AmbiguousCommitError( f"tool={cap.name} timed out with commit status UNKNOWN; " f"idempotent={cap.idempotent} dedup_key_supplied=" f"{dedup_key is not None}. Do not retry; reconcile via " f"get_status(dedup_key) before proceeding." ) from exc if not budget.try_consume(): span.commit_status = CommitStatus.UNKNOWN raise AmbiguousCommitError( f"tool={cap.name} retry budget exhausted during storm; " f"aborting rather than amplifying load." ) from exc # loop: retry with the same dedup_key, which the tool dedups server-side ```