{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-otel-genai-agent-spans-from-silently-collapsing-retried-tool-calls-into-a-single-logical-invocation",
  "title": "Which invariants prevent OTel GenAI agent spans from silently collapsing retried tool calls into a single logical invocation",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`, etc.) where a single logical tool invocation may be retried, hedged, or re-executed across model turns. Does not apply to single-shot, non-retried model calls or to tracing systems that do not carry `trace_id`/`span_id` linkage across agent handoffs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-agent-spans-from-silently-collapsing-retried-tool-calls-into-a-single-logical-invocation.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-agent-spans-from-silently-collapsing-retried-tool-calls-into-a-single-logical-invocation.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-agent-spans-from-silently-collapsing-retried-tool-calls-into-a-single-logical-invocation.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1507,
    "python_slice_tokens": 261,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between a *tool attempt* and a *tool invocation*. The OTel GenAI conventions define attributes for `execute_tool` spans (`gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.tool.type`) and for model client spans (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.request.model`). What the conventions do **not** mandate is...",
    "what_was_observed": "A three-turn agent (plan → tool → synthesize) called a `search_documents` tool. The first attempt hit a 503 from the upstream service; the executor retried after 400 ms and succeeded. Both attempts emitted spans. The model client span for turn 2 reported `gen_ai.usage.input_tokens=1820`, `output_tokens=210`, and the tool span carried `gen_ai.tool.call.id=\"call_9f3a\"` on both attempts because the model had serialized ...",
    "condition_of_validity": "The single-call-ID-per-attempt invariant holds only when all three of the following are true: 1. The executor treats `gen_ai.tool.call.id` as *attempt-scoped*, minting a fresh ID (or appending an attempt suffix such as `call_9f3a#2`) for every re-entry, and never reuses the model-supplied ID as the span's sole identity. 2. The retry loop propagates a stable ...",
    "decision_boundary": "The boundary is whether the agent's retry policy is *inside* or *outside* the span-emitting boundary. - **Retry inside the executor span:** the executor opens one `execute_tool` span, and internal retries are recorded as span *events* (`retry.attempt`, `retry.reason`) on that single span. This is correct and safe — one span, one call ID, attempts visible as ...",
    "operational_effect": "The guardrail is a two-attribute identity contract enforced at the executor boundary, plus a collector-side reconciliation that refuses to fold attempts under a shared key. Concretely: - Every `execute_tool` span carries `gen_ai.tool.call.id` unique to the attempt and `gen_ai.tool.invocation.id` stable across attempts. - The span processor asserts that no tw..."
  },
  "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": "bc334665cf684fb5afe45a413ee149a13556b238537fb04b46f4fbd4e39ccee2",
    "verified_classes": [
      "GenAiSpanIdentityCollision"
    ],
    "verified_functions": [
      "mint_tool_attempt_identity",
      "assert_no_call_id_collision"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAiSpanIdentityCollision"
    ],
    "sample_fail_closed_invariants": [
      "model_call_id is empty; cannot derive attempt identity"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
