{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-handle-span-parenting-collapse-when-a-multi-turn-agent-re-enters-a-tool-loop-under-opentelemetry-genai-semantic-conventions",
  "title": "How should an instance handle span-parenting collapse when a multi-turn agent re-enters a tool loop under OpenTelemetry GenAI semantic conventions",
  "date_of_record": "2026 December 1",
  "scope": "Applies to autonomous agents emitting OpenTelemetry traces under the GenAI semantic conventions (`gen_ai.*`) where a single logical task spans multiple turns, tool invocations, and possible checkpoint/resume cycles. Does not apply to single-shot inference calls or to non-agentic batch pipelines without inter-turn state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-handle-span-parenting-collapse-when-a-multi-turn-agent-re-enters-a-tool-loop-under-opentelemetry-genai-semantic-conventions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-handle-span-parenting-collapse-when-a-multi-turn-agent-re-enters-a-tool-loop-under-opentelemetry-genai-semantic-conventions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-handle-span-parenting-collapse-when-a-multi-turn-agent-re-enters-a-tool-loop-under-opentelemetry-genai-semantic-conventions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1409,
    "python_slice_tokens": 288,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define span attributes (`gen_ai.operation.name`, `gen_ai.request.model`, `gen_ai.usage.input_tokens`, `gen_ai.conversation.id`) but leave the *parenting topology* of a multi-turn agent under-specified. The common-but-wrong assumption is that each turn is a child span of the previous turn, forming a linear chain. The correct inv...",
    "what_was_observed": "A three-turn agent (plan → tool-call → synthesize) was traced with a hand-rolled emitter that set `parent_span_id = previous_span.id`. Turn 2 issued a `gen_ai.tool.call` (`search_kb`) that timed out at the MCP transport layer and was retried after a 4-second backoff. The retry was correctly emitted as a sibling, but the *resumed* turn 3—reconstructed from a checkpoint that persisted only `conversation.id` and the las...",
    "condition_of_validity": "The linear-chain parenting model is valid **only** when all of the following hold: (a) the agent never checkpoints mid-turn, (b) tool retries are emitted as children of the issuing turn rather than siblings, and (c) the trace exporter never rotates buffers across a resume. In practice (b) is the most common violation—retries are semantically children of the ...",
    "decision_boundary": "The decision to re-parent versus fail the emission hinges on whether the resumed turn's causal predecessor is *recoverable*. If the checkpoint persisted the task `span_id` (as a W3C `traceparent` or a stored `span_id`), the turn re-parents to the task root and the trace remains a valid DAG. If the checkpoint persisted only `conversation.id`, the emitter **mu...",
    "operational_effect": "Enforcing the invariant changes two operational behaviors. First, loop-detection becomes reliable: a runaway re-read shows up as N sibling `chat` spans under one task root, and the supervisor's threshold (e.g., >3 siblings with identical `gen_ai.request.model` and rising `input_tokens`) fires correctly. Second, cost attribution moves from the tool node back ..."
  },
  "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": "d48f12e97c03903afad99015f44767fefb2d4acfc22748bdf947f9e8aae2a50d",
    "verified_classes": [
      "SpanParentingError",
      "Span",
      "Checkpoint"
    ],
    "verified_functions": [
      "resolve_parent",
      "emit_resumed_turn"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanParentingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
