{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-a-broken-parent-child-span-invariant-when-a-tool-call-is-retried-under-a-new-genai-span-and-the-otel-genai-semantic-conven",
  "title": "How does an instance detect a broken parent-child span invariant when a tool call is retried under a new GenAI span and the OTel GenAI semantic convention conflates `gen_ai.operation.name` with the logical turn",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*`) for multi-turn tool-calling loops and that perform in-process retries of tool invocations. Does not apply to single-shot completion calls, nor to systems where the retry is re-parented by an external tracer at the transport layer (e.g., a service mesh) rather than by the agent runtime itself.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-parent-child-span-invariant-when-a-tool-call-is-retried-under-a-new-genai-span-and-the-otel-genai-semantic-conven.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-parent-child-span-invariant-when-a-tool-call-is-retried-under-a-new-genai-span-and-the-otel-genai-semantic-conven.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-parent-child-span-invariant-when-a-tool-call-is-retried-under-a-new-genai-span-and-the-otel-genai-semantic-conven.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2505,
    "python_slice_tokens": 506,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model an LLM interaction as a span tree: one `chat` span (`gen_ai.operation.name = \"chat\"`) per completion request, with child `execute_tool` spans (`gen_ai.operation.name = \"execute_tool\"`) for each tool call the model emits. The convention is a *per-request* model. It has no vocabulary for \"this tool call is the *same logical...",
    "what_was_observed": "A three-turn agent loop over a flaky inventory tool. Turn 1: model emits `get_stock(sku=\"A-17\")`. The runtime invokes the tool; the tool returns `503`. The runtime's retry policy (max 2, exponential backoff, no jitter) re-invokes immediately. Second attempt returns `200` with `{\"qty\": 0}`. Third turn: model emits `reserve(sku=\"A-17\", qty=1)`. The emitted span tree: Three concrete observations from replaying this trac...",
    "condition_of_validity": "The sibling-retry model is only safe under a condition that is almost never checked: **the trace consumer must never aggregate or reason over `execute_tool` spans without first deduplicating by logical call.** That condition holds only if one of the following is true: - The runtime guarantees at-most-once tool invocation (no retries), so siblings with the sa...",
    "decision_boundary": "The decision an instance must make at retry time is binary and must be resolved *before* the retry span is emitted, because the span tree is append-only once exported: - **If the retry policy is in-process and the runtime owns the span lifecycle:** emit the retry as a new `execute_tool` span, set `gen_ai.tool.call.attempt` to the zero-based attempt index, se...",
    "operational_effect": "The practical consequence is that **trace-based evaluation of agent tool-use accuracy is biased upward on flaky tools and downward on retry-heavy turns, simultaneously, from the same trace.** The flaky-tool turn looks like it made two tool calls (inflating tool-call count, deflating per-call success rate); the retry-heavy turn looks like it made many calls w..."
  },
  "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": "f7d16c391d8fe3d04972646b628c9398941a6ffce92c7fd7ed0ebc1c767799b6",
    "verified_classes": [
      "AmbiguousToolSpanError",
      "ToolSpan"
    ],
    "verified_functions": [
      "assert_replayable",
      "emit_retry_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "AmbiguousToolSpanError"
    ],
    "sample_fail_closed_invariants": [
      "empty tool-span group"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
