{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-genai-agent-spans-from-silently-losing-tool-call-causality-across-retries",
  "title": "Which invariants prevent GenAI agent spans from silently losing tool-call causality across retries",
  "date_of_record": "2026 November 27",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for LLM invocations and tool executions, particularly when tool calls are retried, deduplicated, or replayed by orchestration layers. Does not address pure LLM-only observability without tool execution, nor non-OTel tracing backends.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-spans-from-silently-losing-tool-call-causality-across-retries.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-spans-from-silently-losing-tool-call-causality-across-retries.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-genai-agent-spans-from-silently-losing-tool-call-causality-across-retries.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1638,
    "python_slice_tokens": 422,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe *what* an LLM or tool operation did (`gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.usage.input_tokens`, `gen_ai.tool.name`, `gen_ai.tool.call.id`), but they do **not** prescribe a causal join key between a `gen_ai.tool.call.id` emitted by the model's tool-call block and the tool-execution span that actually ...",
    "what_was_observed": "A multi-step agent (planner → retrieval tool → summarizer) was instrumented with `gen_ai` spans. The planner emitted a tool call with `gen_ai.tool.call.id = \"call_7f3a\"` and `gen_ai.tool.name = \"vector_search\"`. The executor's first attempt hit a timeout at 30s and the orchestrator retried. The retry used a *new* generated id `call_9b21` (because the model was re-invoked to regenerate the call block on retry). The pa...",
    "condition_of_validity": "The correlation invariant holds only if the orchestrator treats `gen_ai.tool.call.id` as **immutable for the logical call**, not as a per-attempt identifier. The convention's `gen_ai.tool.call.id` is defined as \"the id of the tool call\" from the model's perspective — it is a *logical* identifier, and retries are attempts within that logical call. Therefore: ...",
    "decision_boundary": "The boundary is: **does the orchestrator regenerate the tool-call block on retry, or replay the original?** - If it *replays* the original call block (same arguments, same id), the invariant is trivially preserved; no new span should be created, only a status mutation or child attempt span. - If it *regenerates* (new id), the invariant is violated unless the...",
    "operational_effect": "Without the invariant, three concrete degradations occur: (1) evaluation harnesses that join on call-id score retries as failures, poisoning agent-quality metrics; (2) token accounting double-counts retried prompts, inflating cost-per-task and mis-tuning budget guards; (3) RAG attribution breaks — retrieved documents cannot be traced to the model turn that c..."
  },
  "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": "410fc9e5b863f4f16f90cab34c2c6974e1b696136d1ecc64f52f8cc2b194f04d",
    "verified_classes": [
      "ToolCallCausalityError",
      "Span"
    ],
    "verified_functions": [
      "record_tool_attempt",
      "resolve_call"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ToolCallCausalityError"
    ],
    "sample_fail_closed_invariants": [
      "replacement retry must carry a new call id, not the original"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
