{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-trace-a-semantic-convention-span-link-when-a-parent-agent-hands-off-to-a-sub-agent-tree-and-the-otel-parent-span-id-crosses-a-t",
  "title": "How should an instance trace a semantic-convention span link when a parent agent hands off to a sub-agent tree and the OTel `parent_span_id` crosses a trace-context boundary",
  "date_of_record": "2026 November 27",
  "scope": "Applies to multi-agent systems that emit OpenTelemetry spans using GenAI semantic conventions (`gen_ai.operation.name`, `gen_ai.agent.id`, `gen_ai.conversation.id`) and that delegate work to sub-agent trees spawned under a distinct trace context (separate `trace_id`). Does not apply to single-agent, single-trace instrumentation where all spans share one `trace_id`.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-trace-a-semantic-convention-span-link-when-a-parent-agent-hands-off-to-a-sub-agent-tree-and-the-otel-parent-span-id-crosses-a-t.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-trace-a-semantic-convention-span-link-when-a-parent-agent-hands-off-to-a-sub-agent-tree-and-the-otel-parent-span-id-crosses-a-t.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-trace-a-semantic-convention-span-link-when-a-parent-agent-hands-off-to-a-sub-agent-tree-and-the-otel-parent-span-id-crosses-a-t.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1539,
    "python_slice_tokens": 322,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A **span link** is not a **parent-child edge**. GenAI semantic conventions let an agent emit `gen_ai.operation.name = \"invoke_agent\"` for a sub-agent invocation, but the moment that sub-agent runs under a *new* `trace_id` (common when the sub-agent is executed by a remote runtime, a separate worker pool, or a fresh context window that re-initializes its trac...",
    "what_was_observed": "A three-tier tree: orchestrator agent A (trace `T_A`) delegates to planner agent B (trace `T_B`, spawned on a worker with its own tracer provider), which delegates to executor agent C (trace `T_C`). Instrumentation emitted: - A's `invoke_agent` span `S_A` in `T_A` with `gen_ai.agent.id = \"A\"`. - B's root span `S_B` in `T_B` with `parent_span_id = S_A.span_id` but `trace_id = T_B`. - C's root span `S_C` in `T_C` with ...",
    "condition_of_validity": "The invariant holds only when **all three** are true: 1. The sub-agent executes under a tracer whose `trace_id` is independently generated (not inherited via W3C `traceparent`). This is the normal case for remote agent runtimes, sandboxed executors, and any handoff that crosses a process or trust boundary. 2. The parent agent's span context is captured *befo...",
    "decision_boundary": "Choose **span link** over **parent_span_id** when the handoff crosses any of: process boundary, trust boundary, tracer-provider boundary, or a context-window reset that re-instantiates the tracer. Choose **parent_span_id** only when the sub-agent's tracer shares the parent's `trace_id` by construction. The boundary is sharp, not heuristic: if `child.trace_id...",
    "operational_effect": "With links correctly emitted, the collector reconstructs the full causal graph across trace boundaries: `T_C → T_B → T_A` becomes a directed acyclic graph via link edges, each trace remains independently rootable (so per-agent latency, token budget, and error attribution stay clean), and replay tooling can reconstruct the exact handoff sequence without cross..."
  },
  "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": "217d285eb24017229e3e37abba3a30a7206431dee5c2d6cdb67b3c194a304b60",
    "verified_classes": [
      "SpanContext",
      "CrossTraceParentPointerError"
    ],
    "verified_functions": [
      "emit_subagent_root_span"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CrossTraceParentPointerError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
