{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-distributed-trace-linkage-when-a-subagent-re-emits-its-parent-s-span-context-after-a-context-window-compaction",
  "title": "Why does an instance lose distributed trace linkage when a subagent re-emits its parent's span context after a context-window compaction",
  "date_of_record": "2026 November 20",
  "scope": "Applies to multi-agent systems that propagate OpenTelemetry-style span context (trace_id, span_id, trace_flags, plus GenAI semantic convention attributes such as `gen_ai.operation.name`, `gen_ai.agent.id`, `gen_ai.tool.name`) across orchestrator→subagent→tool boundaries via serialized context tokens. Does not apply to single-process agents that emit spans from a shared in-memory context manager, nor to systems where the trace backend reconstructs linkage server-side from a durable event log.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-distributed-trace-linkage-when-a-subagent-re-emits-its-parent-s-span-context-after-a-context-window-compaction.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-distributed-trace-linkage-when-a-subagent-re-emits-its-parent-s-span-context-after-a-context-window-compaction.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-distributed-trace-linkage-when-a-subagent-re-emits-its-parent-s-span-context-after-a-context-window-compaction.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1557,
    "python_slice_tokens": 292,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"traces are missing.\" The failure is that traces are *present but mis-parented* — a subagent re-emits a span whose `parent_span_id` points to a span that no longer exists in the orchestrator's exported trace, because the subagent's span context was captured *before* a compaction event that invalidated the originating span's lifetime. The d...",
    "what_was_observed": "An orchestrator agent (call it O) dispatched a research task to subagent S with a serialized span context token: `{trace_id: T, span_id: A, trace_flags: 0x01}` where A is O's active `invoke_agent` span. S ran for 14 tool calls. At call 9, S's context window saturated and a compaction routine summarized the message history, dropping the original dispatch envelope — including the raw context token — and replacing it wi...",
    "condition_of_validity": "The invariant that must hold for linkage to remain sound is: > For any span emitted by an agent instance, the referenced `parent_span_id` must (a) be open at the time of emission, or be explicitly marked as a *link* (not a parent) to a closed span; and (b) carry a `trace_flags` byte byte-identical to the parent's, unless the child is a deliberate root. This ...",
    "decision_boundary": "The architectural fork is whether the span context is **content** or **metadata**. If it is content — something the model reads, reasons over, and can be summarized — then it is subject to probabilistic rewriting and the linkage invariant is unenforceable. If it is metadata — a slot the runtime injects and the model never sees as text — then compaction canno...",
    "operational_effect": "Without the guardrail, the observable symptom is a trace tree that under-reports subagent work precisely when the subagent worked *longest* — the tasks most worth tracing are the ones most likely to cross a compaction boundary, so the failure is anti-correlated with trace value. Tail-sampling amplification makes it worse: a single dropped flag in a long suba..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "101b4f5380f5c5325b46c5f2382a59481aa9ff34290018dae66517ac18293546",
    "verified_classes": [
      "SpanLinkageError",
      "SpanContext",
      "Span"
    ],
    "verified_functions": [
      "emit_child_span",
      "make",
      "verify"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SpanLinkageError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "time"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
