{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-its-reasoning-lineage-when-genai-spans-are-parented-to-the-tool-call-span-instead-of-the-generation-span",
  "title": "Why does an instance lose its reasoning lineage when GenAI spans are parented to the tool-call span instead of the generation span",
  "date_of_record": "2026 November 25",
  "scope": "Applies to any agent runtime that emits OpenTelemetry `gen_ai.*` spans and relies on trace topology (parent/child links) to reconstruct the causal chain of a multi-step tool-using turn. Does not apply to flat, single-span-per-turn instrumentation, nor to systems that carry full reasoning state in span attributes independent of parentage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-reasoning-lineage-when-genai-spans-are-parented-to-the-tool-call-span-instead-of-the-generation-span.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-reasoning-lineage-when-genai-spans-are-parented-to-the-tool-call-span-instead-of-the-generation-span.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-its-reasoning-lineage-when-genai-spans-are-parented-to-the-tool-call-span-instead-of-the-generation-span.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1842,
    "python_slice_tokens": 279,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things a GenAI trace is asked to represent, and they are conflated by the current semantic conventions: 1. **Temporal containment** — \"this tool call happened *while* the model was producing this turn.\" This is what a naive parent/child edge encodes: the tool span is a child of the span that was active when the tool was i...",
    "what_was_observed": "A three-step agent turn: generation G1 (decides to call `search`), tool T1 (`search`), generation G2 (consumes T1 result, decides to call `fetch`), tool T2 (`fetch`), generation G3 (final answer). Intended lineage: Observed lineage in the exported trace (streaming runtime, generation span closed on stream `finish` event before tool dispatch): Every span carries correct `gen_ai.*` attributes. `T1` has `gen_ai.tool.nam...",
    "condition_of_validity": "The parent-edge-as-lineage invariant holds only when: - The generation span remains `active` (on the context stack) for the entire duration in which its selected tool spans are created, **or** - The instrumentor explicitly passes the generation span's `SpanContext` as the parent when starting each tool span, regardless of ambient context, **or** - Lineage is...",
    "decision_boundary": "The architectural decision is whether to treat the parent edge as **authoritative lineage** or as **mere temporal containment**, and instrument accordingly: - If parent edge is authoritative lineage → the generation span MUST NOT end until all tool spans it selected have been started with it as explicit parent. This forces the runtime to either keep generati...",
    "operational_effect": "When the invariant breaks, three downstream capabilities degrade silently: 1. **Replay fidelity** — a replay engine reconstructing the turn from spans will reorder tool calls by timestamp rather than by causal selection, producing a different tool-call sequence than the original run when tool latencies overlap. Replay diverges from the recorded run without a..."
  },
  "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": "6212c746b0d18e1c637fa56c573ff9cf9ee76b39fe275464a2823ea5681c1d56",
    "verified_classes": [
      "LineageInvariantViolation",
      "Span"
    ],
    "verified_functions": [
      "validate_lineage"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "LineageInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
