{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-attribution-when-opentelemetry-genai-spans-are-emitted-from-a-resumed-agent-turn",
  "title": "Why does an instance lose tool-call attribution when OpenTelemetry GenAI spans are emitted from a resumed agent turn",
  "date_of_record": "2026 November 19",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for tool invocations and per-turn token accounting, and that support mid-task checkpoint/resume or cross-process handoff. Does not apply to single-shot, single-process inference calls where span context is created and closed within one uninterrupted execution frame.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-attribution-when-opentelemetry-genai-spans-are-emitted-from-a-resumed-agent-turn.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-attribution-when-opentelemetry-genai-spans-are-emitted-from-a-resumed-agent-turn.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-attribution-when-opentelemetry-genai-spans-are-emitted-from-a-resumed-agent-turn.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1746,
    "python_slice_tokens": 322,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a tool call as a *child span of the agent turn span* whose `trace_id`/`span_id` parent linkage carries the causal attribution, and they model token usage as attributes (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`) attached to the span that *produced* the completion. The conventions assume a monotonic, single...",
    "what_was_observed": "A multi-tool research agent (planner → 4 parallel retrieval tools → synthesizer) checkpointed after the planner turn and again after tool dispatch, resuming in a fresh worker process. Instrumentation used the OTel Python SDK with a `TracerProvider` re-initialized per process and `gen_ai.operation.name=execute_tool` child spans for each retrieval. Post-resume traces exhibited three concrete artifacts: 1. **Orphaned to...",
    "condition_of_validity": "The invariant that holds in uninterrupted execution — *every tool call and every token delta of a logical turn is reachable from the turn's root span by parent traversal* — is **valid only when the turn's `SpanContext` is captured at checkpoint and re-attached on resume as the parent of the resumed root.** Formally, resume is safe iff: - the checkpoint paylo...",
    "decision_boundary": "The boundary is between **checkpointing execution state** and **checkpointing observability state**. Agent runtimes routinely serialize the former (messages, tool queue, scratchpad) and treat the tracer as ambient infrastructure that \"just works\" across process boundaries. It does not: `SpanContext` is not in the serialized state, and the OTel SDK's context ...",
    "operational_effect": "The practical consequence is that token-cost dashboards and tool-latency SLOs computed from these traces are wrong in a *bounded but non-obvious* way: they over-count input tokens by the replay factor (one full re-emission per resume) and under-count tool latency (orphaned tool spans are excluded from the turn's critical path because they have no parent link..."
  },
  "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": "a6790248bd15139b1c3b1d734bb285f629af3e8c98a64f7a2f28528f664695a0",
    "verified_classes": [
      "CheckpointSpanContextError",
      "SpanContext",
      "Checkpoint"
    ],
    "verified_functions": [
      "write_checkpoint",
      "resume_turn",
      "is_valid"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CheckpointSpanContextError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
