{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-span-attribute-collapse-when-opentelemetry-genai-tool-call-spans-are-emitted-from-a-retried-or-re-entrant-agent-step",
  "title": "How does an instance detect span-attribute collapse when OpenTelemetry GenAI tool-call spans are emitted from a retried or re-entrant agent step",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, plus `gen_ai.system`/`gen_ai.request.model`) for tool-call tracing, where a single logical step may be retried, replayed, or re-entered after a checkpoint resume. Does not apply to stateless one-shot inference calls with no retry or resume path, nor to spans emitted by a collector-side processor that has already deduplicated by trace/span ID.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-collapse-when-opentelemetry-genai-tool-call-spans-are-emitted-from-a-retried-or-re-entrant-agent-step.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-collapse-when-opentelemetry-genai-tool-call-spans-are-emitted-from-a-retried-or-re-entrant-agent-step.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-collapse-when-opentelemetry-genai-tool-call-spans-are-emitted-from-a-retried-or-re-entrant-agent-step.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1864,
    "python_slice_tokens": 319,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI conventions treat a span as a *record of one model or tool invocation*. Agent runtimes, however, treat a step as an *idempotent logical unit that may execute more than once*. When these two models disagree, the observable symptom is not a missing span but a **span-attribute collapse**: multiple physical executions of the same logical tool call are ...",
    "what_was_observed": "A planner agent invokes a `search_documents` tool. The tool call exceeds the client-side deadline, the transport layer surfaces a timeout, and the agent's retry wrapper re-issues the identical call with the same `gen_ai.tool.call.id` (correctly, for idempotency at the tool layer). Two spans are emitted with identical `trace_id`, `span_id` is *not* identical but the runtime's span exporter has been configured with `ge...",
    "condition_of_validity": "The collapse is only possible under a conjunction of three conditions, and bounding it requires breaking at least one: 1. **Call-ID reuse across executions.** The runtime propagates `gen_ai.tool.call.id` from the first attempt into the retry, either because the tool requires idempotency keys or because the span context is inherited from the parent step. This...",
    "decision_boundary": "The instance must decide, at span-emission time, whether it is emitting the *first* execution of a logical call or a *re-execution*. The boundary is drawn by asking: **does a span for this `gen_ai.tool.call.id` already exist in the current trace context, and is the current execution a retry/resume of the same logical step?** - If no prior span exists → emit ...",
    "operational_effect": "When the collapse occurs undetected, three downstream consumers are poisoned simultaneously: the **token-budget guard** under-counts spend (it reads the surviving span's usage, which is the cheaper of the two executions or a hybrid), the **auditor replay** cannot reconcile trace against ledger (token deltas with no attributable call), and the **failure-attri..."
  },
  "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": "5502b7bf5b8c104c85257139e7fb88f8c694225b2185b2b825a4d73f4ef22e20",
    "verified_classes": [
      "SpanAttributeCollapseError",
      "GenAISpan",
      "SpanIdentityGuard"
    ],
    "verified_functions": [
      "replay_retry_sequence",
      "__init__",
      "close",
      "emit"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpanAttributeCollapseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
