{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-otel-genai-span-trees-from-silently-orphaning-tool-call-attributes-across-agent-retries",
  "title": "Which invariants prevent OTel GenAI span trees from silently orphaning tool-call attributes across agent retries",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes) where a single logical task fans out into nested spans (`invoke_agent` → `execute_tool` → `chat`), and where any span in that tree may be retried, resumed from a checkpoint, or re-emitted by a different process. Does not apply to flat single-span instrumentation or to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-span-trees-from-silently-orphaning-tool-call-attributes-across-agent-retries.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-span-trees-from-silently-orphaning-tool-call-attributes-across-agent-retries.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-otel-genai-span-trees-from-silently-orphaning-tool-call-attributes-across-agent-retries.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1896,
    "python_slice_tokens": 309,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.operation.name`, `gen_ai.tool.name`, and `gen_ai.tool.call.id` as *attributes on a span*, not as a *correlation key across spans*. That distinction is load-bearing and routinely violated. A tool call is modeled as an `execute_tool` span whose `gen_ai.tool.call.id` names the logical invocation, and whose parent is ...",
    "what_was_observed": "A three-hop agent (plan → tool → summarize) instrumented with `opentelemetry-instrumentation` and manual `invoke_agent` / `execute_tool` spans. The tool executor ran as an async worker off the main agent loop, consuming a queue of tool-call requests. On the happy path, the worker created `execute_tool` spans inside a `contextvars`-propagated context captured at enqueue time, so `parent_span_id` pointed at the request...",
    "condition_of_validity": "The convention's implicit assumption holds only when: (a) the parent span remains open for the full lifetime of every child it spawns, and (b) `gen_ai.tool.call.id` is unique per logical invocation and never reused across retries. Both are false in any agent that (a) closes the model-turn span before executing the tool asynchronously, or (b) retries a tool c...",
    "decision_boundary": "The boundary is whether the tool executor can *reconstruct* the anchor at child-span creation time from durable state alone. If the executor holds only an in-memory `contextvars` snapshot, it is on the wrong side of the boundary: a checkpoint resume or a retry that crosses a process boundary loses the parent and the child orphans silently. If the executor ho...",
    "operational_effect": "Without the anchor attribute, three operational queries fail: (1) error attribution — a failed retried tool call cannot be tied to the model turn that requested it, so you cannot tell whether the model or the tool was at fault; (2) latency accounting — the retry's duration is dropped by dedup, under-reporting tool latency by the retry factor; (3) sampling co..."
  },
  "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": "3a850a3dc9bcd3fa21ee4bbca89b8ab73327081960f025c490e9458bd3fc9f98",
    "verified_classes": [
      "OrphanedToolCallError",
      "ToolRequest"
    ],
    "verified_functions": [
      "resolve_anchor",
      "emit_tool_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "OrphanedToolCallError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
