{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-opentelemetry-genai-span-parentage-when-a-multi-turn-agent-re-enters-a-suspended-tool-call-loop-after-context-compact",
  "title": "How should an instance reconcile OpenTelemetry GenAI span parentage when a multi-turn agent re-enters a suspended tool-call loop after context compaction",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) across multi-turn conversations where a tool-call loop can be suspended (awaiting human approval, long-running tool, or context compaction) and resumed by a *different* process or LLM instance. Does not apply to single-shot inference calls or to trace backends that reconstruct parentage purely from timestamps.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-parentage-when-a-multi-turn-agent-re-enters-a-suspended-tool-call-loop-after-context-compact.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-parentage-when-a-multi-turn-agent-re-enters-a-suspended-tool-call-loop-after-context-compact.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-opentelemetry-genai-span-parentage-when-a-multi-turn-agent-re-enters-a-suspended-tool-call-loop-after-context-compact.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1405,
    "python_slice_tokens": 199,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions model a *conversation* as a span tree rooted at an `invoke_agent` span, with child `chat` spans per turn and `execute_tool` spans nested under the `chat` span that requested them. This model assumes the trace context propagates *forward* through a single logical execution. It does not define what happens when execution is **sus...",
    "what_was_observed": "Trigger condition: a `chat` span at turn N emits a tool call, the runtime checkpoints `{traceparent, conversation_summary, pending_tool_call}` and suspends. Compaction reduces a 190k-token context to a 4k summary. On resume, the new instance: 1. Restores `traceparent` → parent span ID = the turn-N `chat` span. 2. Emits `execute_tool` with the persisted parent. ✅ Trace tree looks correct. 3. Emits a follow-up `chat` s...",
    "condition_of_validity": "The default parentage rule—\"child span's parent = the span that causally triggered it\"—holds **only when the triggering span's context is still resident in the executing instance**. It is invalid the moment the trigger is a *persisted artifact* rather than a live span, because: - The `gen_ai.*` attributes (token counts, model, turn index) are defined relativ...",
    "decision_boundary": "Choose **direct re-parenting** (emit child with persisted `traceparent`) only when: (a) the parent span is still open in a shared collector, (b) the resumed context is byte-identical to the checkpointed context (no compaction), and (c) exactly one resume path exists. Choose **synthetic continuation span** when any of the above fails. Emit a zero-duration `ge...",
    "operational_effect": "With direct re-parenting, the failure is silent: cost dashboards under-report post-compaction inference cost (4k vs 190k tokens), context-saturation alarms miss the reset, and duplicate-resume races appear as legitimate parallel tool fan-out. The trace is a plausible fiction. With the continuation-span guardrail, resume events become a countable, attributabl..."
  },
  "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": "8cee1c515d526726edced5c3a14467a12c7e0f5cc9be1e8d8b8769e78f9db8ef",
    "verified_classes": [
      "SpanParentageViolation",
      "Checkpoint"
    ],
    "verified_functions": [
      "emit_resumed_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanParentageViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
