{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-lineage-when-opentelemetry-genai-span-attributes-are-exported-asynchronously-across-a-checkpoint-boundary",
  "title": "Why does an instance lose tool-call lineage when OpenTelemetry GenAI span attributes are exported asynchronously across a checkpoint boundary?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for tool calls and token accounting, where the span processor is a batching exporter and the agent checkpoints/resumes mid-task. Does not apply to synchronous simple-span-processor setups with no checkpoint/resume, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-lineage-when-opentelemetry-genai-span-attributes-are-exported-asynchronously-across-a-checkpoint-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-lineage-when-opentelemetry-genai-span-attributes-are-exported-asynchronously-across-a-checkpoint-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-lineage-when-opentelemetry-genai-span-attributes-are-exported-asynchronously-across-a-checkpoint-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1672,
    "python_slice_tokens": 216,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"spans get dropped.\" It is a **causal-parent discontinuity**: the `trace_id`/`span_id` linkage that a downstream consumer uses to reconstruct tool-call lineage is fixed at span *creation* time and carried in the span's immutable `SpanContext`, but the *attributes* that describe token accounting (`gen_ai.usage.input_tokens`, `gen_ai.usage.o...",
    "what_was_observed": "A tool-invoking agent loop (model call → `execute_tool` span → result → model call) ran under a batching `BatchSpanProcessor` with a 5s export interval. A checkpoint was taken after the model emitted a tool call but before the tool returned. The process was killed (deploy) and resumed from checkpoint in a new process. Trace evidence from the collector: - Original process: `gen_ai.tool.name=\"search\"` span `span_id=A` ...",
    "condition_of_validity": "The duplication-and-orphaning behavior is *bounded* (not silently corrupting) only when all of the following hold: 1. The `SpanContext` (trace_id, span_id, trace_flags) is serialized into the checkpoint, not just the conversation state. If it is, the resumed process can re-parent span `B` under `A`'s context and the lineage survives — provided the collector ...",
    "decision_boundary": "The architectural choice is: **where does the checkpoint boundary sit relative to span lifetime?** - *Boundary inside a span* (checkpoint taken while a tool span is open): requires `SpanContext` serialization + call-id persistence + a reconciler keyed on call-id. Without all three, do not checkpoint here. - *Boundary at a span edge* (checkpoint only between ...",
    "operational_effect": "Downstream, the lineage consumer sees two traces where there was one logical task. Cost dashboards double-count the tool-call prompt (attributed to `R1` with no tool span, and implicitly re-derived in `R2`'s input tokens) or, worse, *under*-count because the abandoned span `A` was never exported at all. Latency attribution is wrong: the tool's wall-clock tim..."
  },
  "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": "13bf29468aa0a88508610f5ddf1b73864ffbcda5e0cb6676a2614db9e4f3734c",
    "verified_classes": [
      "LineageDiscontinuityError"
    ],
    "verified_functions": [
      "resume_task"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "LineageDiscontinuityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
