{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-trace-context-collapse-when-a2a-handoff-spans-are-re-parented-across-agent-runtimes",
  "title": "Which invariants prevent trace-context collapse when A2A handoff spans are re-parented across agent runtimes",
  "date_of_record": "2026 November 21",
  "scope": "Applies to multi-agent systems emitting OpenTelemetry-style traces where an orchestrator agent invokes a remote agent over an A2A/MCP transport and the receiving agent runtime starts a new trace root instead of continuing the caller's `trace_id`/`span_id`. Does not cover single-process agent loops, nor transports that natively propagate W3C `traceparent` headers end-to-end without re-serialization.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-context-collapse-when-a2a-handoff-spans-are-re-parented-across-agent-runtimes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-context-collapse-when-a2a-handoff-spans-are-re-parented-across-agent-runtimes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-trace-context-collapse-when-a2a-handoff-spans-are-re-parented-across-agent-runtimes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1933,
    "python_slice_tokens": 453,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two semantically different things a \"handoff span\" can mean, and GenAI semantic conventions conflate them: 1. **A causal child span** — the remote agent's work is a descendant of the caller's span, sharing one `trace_id`. Correct when the remote call is synchronous and the caller blocks on the result. 2. **A linked root span** — the remote agent's ...",
    "what_was_observed": "An orchestrator agent (`planner`) calls a specialist agent (`retriever`) over an A2A JSON-RPC endpoint. The planner emits a client span `gen_ai.agent.invoke` with `trace_id=T1`, `span_id=S1`. The A2A request payload includes a `metadata.trace` object carrying `traceparent` as a JSON field — not as an HTTP header, because the A2A spec models transport metadata as a body field. The retriever's runtime uses an OTel SDK ...",
    "condition_of_validity": "The re-parenting failure is bounded by a single invariant that must hold at the receiving runtime **before the first span is created**: > For any inbound agent-to-agent request carrying a handoff context, the receiving runtime MUST resolve the effective parent (`trace_id`, `span_id`, `trace_flags`) from *all* transport surfaces the protocol permits — headers...",
    "decision_boundary": "The choice between continuing (a) and linking (b) is governed by the caller's lifetime relative to the callee's: - **Continue as child** when the caller blocks on the response and the callee's lifetime is strictly nested within the caller's span. This preserves the single-`trace_id` invariant that makes duration and error-propagation queries correct. - **Lin...",
    "operational_effect": "Once the invariant holds, three downstream properties become computable that were previously silently broken: - **Handoff latency** is the child span's start minus parent span's end, or for linked roots, the link timestamp delta. Both are index-level operations. - **Sampling coherence** requires that a continued child inherits `trace_flags` from the parent's..."
  },
  "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": "b163982822dd2d7fa32deb628b4d4b1195fcad4fbec8820ca53a9790661b04c7",
    "verified_classes": [
      "TraceContextCollapseError",
      "InboundHandoff",
      "EmittedSpan"
    ],
    "verified_functions": [
      "_parse_traceparent",
      "resolve_effective_parent",
      "start_receiver_span"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TraceContextCollapseError"
    ],
    "sample_fail_closed_invariants": [
      "Inbound handoff declares no resolvable traceparent on any surface"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
