{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-trace-parentage-when-a-nested-agent-re-emits-its-own-span-context",
  "title": "Why does an instance lose trace parentage when a nested agent re-emits its own span context",
  "date_of_record": "2026 November 28",
  "scope": "Applies to multi-agent systems where a parent agent invokes a child agent (or a tool that itself runs an LLM loop) and both layers emit OpenTelemetry-style spans into a shared collector. Does not apply to single-process, single-agent traces with no nested span emission, nor to systems using a single flat span table keyed only by `trace_id`.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-trace-parentage-when-a-nested-agent-re-emits-its-own-span-context.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-trace-parentage-when-a-nested-agent-re-emits-its-own-span-context.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-trace-parentage-when-a-nested-agent-re-emits-its-own-span-context.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1792,
    "python_slice_tokens": 398,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing spans\" and it is not \"broken sampling.\" It is **parentage inversion caused by context re-injection at the agent boundary**. When an agent invokes a sub-agent, two things are true simultaneously: 1. The sub-agent is a *new* execution context — a fresh LLM instance with its own span emitter, its own `trace_id` generation policy, and...",
    "what_was_observed": "A three-tier pipeline: `orchestrator → retriever_agent → summarizer_agent`. Each tier is a separate process behind an MCP-style transport. The orchestrator emitted span `orch.dispatch` with `trace_id = T0`, `span_id = S1`. It passed `traceparent: 00-T0-S1-01` in the tool-call arguments. Observed in the collector: - `retriever_agent` emitted `retr.plan` with `trace_id = T0`, `parent_span_id = S1` — **correct**, becaus...",
    "condition_of_validity": "The correct-parentage invariant holds **only if** all three of the following are enforced at the agent boundary: 1. **Header authority is the caller's live context, not the payload.** The `traceparent` used for a child span MUST be read from the transport envelope at emission time, never from a field inside the task/memory object that may have been carried f...",
    "decision_boundary": "The boundary is: **does the sub-agent construct its span before or after it parses the task payload?** - If it constructs the span from the *transport envelope* (the MCP/A2A message metadata) → correct parentage. - If it constructs the span from the *task payload* (the JSON the LLM was asked to reason over) → stale parentage, because the payload's `tracepare...",
    "operational_effect": "Without the assertion, the observable symptoms are: - **Latency misattribution** — nested time is charged to the root, so the retriever looks like the bottleneck when it is the summarizer. - **Cost attribution collapse** — token spend per sub-agent cannot be summed per parent because the parent-child edge is gone. - **Replay divergence** — a failed run canno..."
  },
  "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": "01e44f6ed78c4ad9d138f159095a21677396a9bf1952479fb3228b0ab8ffbff0",
    "verified_classes": [
      "TraceParentageError",
      "SpanContext",
      "EmittedSpan"
    ],
    "verified_functions": [
      "emit_child_span",
      "dispatch_to_subagent"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TraceParentageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
