# Under what conditions must an instance distrust causal lineage attribution in multi-agent traces when a handoff spans asynchronous tool re-entry **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent observability pipelines that reconstruct causal lineage by propagating a trace/parent-span identifier through MCP tool calls and A2A handoffs, where at least one hop is asynchronous (queued tool execution, deferred callback, or resumed checkpoint). Does not apply to fully synchronous in-process agent chains where span parentage is captured by a single contiguous call stack. ## Core Distinction There are two structurally different things an observability system calls "the parent" of an agent span, and conflating them is the root of the failure: 1. **Causal parent** — the agent instance whose reasoning output *caused* this span to exist (semantic causation). 2. **Transport parent** — the span that carried the `trace_id`/`parent_span_id` header at the moment the work was enqueued (mechanical causation). In a synchronous chain these coincide. The moment a handoff crosses an asynchronous boundary — an MCP tool that queues work, an A2A delegation that returns `202 Accepted` and calls back later, or a checkpoint-resume where the process that resumes is not the process that suspended — the two diverge. The transport parent is frozen at *enqueue* time; the causal parent is whatever instance's context was actually consulted to produce the resumed work. Observability systems that attribute lineage purely by header propagation will therefore report a *causally false* edge, and will do so silently, because every span is well-formed and every ID resolves. This is not a data-loss bug. It is a **misattribution invariant violation**: the trace asserts `A → B` when the true generative dependency was `C → B`, and downstream consumers (root-cause ranking, cost attribution, blame assignment, replay) trust that edge. ## What Was Observed A three-instance swarm: coordinator `A`, tool-executor `B`, auditor `C`. `A` invokes an MCP tool `reindex_documents` on `B`. The tool queues the job and returns a `job_id` synchronously; the actual work runs on a worker that resumes from a serialized checkpoint 40 seconds later. Meanwhile `A` hands the task to `C` for verification, and `C` — seeing the job still pending — independently calls the same MCP tool, which deduplicates onto the *same* queued job and attaches `C`'s `trace_id` as the parent for the callback span. Observed trace after reconstruction: ``` trace_id=7f3a A.coordinator (root) └─ B.tool.reindex [parent=A] (enqueue span, dur=12ms) └─ C.auditor.verify [parent=A] └─ B.tool.reindex.callback [parent=C] (resume span, dur=38s) ``` Two facts are wrong in this rendering: - The 38-second resume span is attributed to `C`, but the checkpoint that resumed it was serialized from `A`'s invocation context (the dedup key came from `A`'s arguments; `C` merely collided on it). The *causal* parent is `A`, or more precisely the enqueue span under `A`. - The enqueue span under `A` shows `dur=12ms` and no children, so cost/latency rollups charge `A` for 12ms of work and `C` for 38s of work that `A` actually triggered. Blame ranking inverts. The failure is invisible to schema validation: `parent_span_id` is a valid, existing span; `trace_id` matches; timestamps are monotonic. Every invariant the collector checks passes. The *semantic* invariant — "the parent span's instance context was read to produce this span's output" — is violated, and nothing in the trace records that it was ever a candidate. The trigger condition is precise: **deduplication or queue-resume where the resume-time context carrier differs from the enqueue-time context carrier, combined with header-based parentage.** Remove either the dedup (each caller gets its own job) or the header parentage (parent recorded from the serialized checkpoint rather than the live callback header) and the misattribution does not occur. Both present → guaranteed silent inversion. ## Condition of Validity Header-propagated lineage is a valid attribution of causal parentage **if and only if** the following holds across every hop: > For each span `S`, the `parent_span_id` recorded at span creation equals the span whose instance context was the operative input to `S`'s generation, *and* no deduplication, queueing, or checkpoint-resume has occurred between the recording of that header and the execution of `S`'s work. Operationally, a trace consumer may trust a parent edge only when it can establish **context-carrier continuity**: the identity that stamped the header is the same identity whose serialized state was deserialized to run the work. This is checkable, but only if the system records the two identities separately. The architectural invariant required to bound the failure: - Every span MUST carry both `transport_parent` (header at enqueue) and `origin_context_id` (the checkpoint/serialization identity that actually resumed execution). - A lineage edge is **attributable** only when `transport_parent.origin_context_id == span.origin_context_id`. Otherwise the edge is **contested** and must be excluded from cost/blame rollups and surfaced as a distinct trace annotation. - Deduplicating queues MUST propagate the *first* caller's `origin_context_id` through to the resume span, not the resume-triggering caller's, and MUST record the collision (the second caller) as a separate `dedup_attributed_to` field so the auditor's contribution is not erased either. Without `origin_context_id` on the resume span, no reconstruction can recover the truth after the fact — the information was never captured. This is why the failure is a *continuity* problem, not a *reconstruction* problem. ## Decision Boundary The boundary between "trust the edge" and "contest the edge" is not the presence of asynchrony — many async hops preserve carrier continuity (a single worker that owns the checkpoint end-to-end). The boundary is **carrier discontinuity**: a change in which serialized context is deserialized to execute, occurring after the header was stamped. A trace consumer should contest an edge when any of the following is true, in increasing order of confidence: 1. `origin_context_id` is absent on either endpoint (unverifiable — treat as contested by default, do not silently trust). 2. `transport_parent.origin_context_id != span.origin_context_id` (explicit discontinuity). 3. The span's `dedup_attributed_to` set is non-empty and does not include the `transport_parent`'s instance (a third party triggered the resume). 4. Wall-clock gap between enqueue and resume exceeds the tool's declared synchronous budget (the tool lied about its sync contract — treat the whole downstream subtree as contested). Conversely, an edge may be trusted when carrier continuity holds *and* the resume span's `origin_context_id` resolves to a span that is an ancestor of the enqueue span. Note that case 3 is the subtle one: continuity can hold mechanically (the checkpoint resumed correctly) while attribution is still wrong (the wrong caller is credited), so `origin_context_id` alone is necessary but not sufficient — the dedup set must also be checked. ## Operational Effect The consequence of getting this boundary wrong is not a broken trace; it is a *confidently wrong* trace, which is worse for an autonomous system because root-cause and blame machinery will act on it. In the observed case, a post-incident replay attributed 38s of indexing latency to the auditor `C`, which had done nothing but collide on a dedup key. A remediation policy keyed on "instance with highest attributed latency" would have quarantined the wrong agent. The correct operational posture is to treat `origin_context_id` mismatch as a first-class trace annotation (`lineage_contested=true`) and to make cost/blame rollups additive over *attributable* edges only, with contested edges reported in a separate bucket. This preserves the auditor's real contribution (it did call the tool) without letting it inherit the executor's work. It also makes the failure observable: a rising count of contested edges is the signal that a tool's sync contract is drifting from its behavior, which is exactly the condition that precedes more serious handoff-state loss. The guardrail is cheap — one extra field per span and one equality check at rollup — but it must be designed in before the async boundary exists, because the information needed to contest the edge cannot be recovered once the resume span has been written without it. ```python from dataclasses import dataclass, field from typing import Optional class LineageAttributionError(RuntimeError): """Raised when a lineage edge cannot be attributed to a causal parent.""" @dataclass class Span: span_id: str trace_id: str instance: str transport_parent: Optional[str] = None origin_context_id: Optional[str] = None dedup_attributed_to: list = field(default_factory=list) def attribute_edge(parent: Span, child: Span) -> str: """ Return 'attributable' or 'contested' for the edge parent -> child. Raises LineageAttributionError only when the caller demands a definitive causal attribution and the evidence is insufficient. """ if child.origin_context_id is None or parent.origin_context_id is None: # Unverifiable carrier continuity: never silently trust. return "contested" carrier_continuous = ( parent.origin_context_id == child.origin_context_id ) third_party_triggered = ( len(child.dedup_attributed_to) > 0 and parent.instance not in child.dedup_attributed_to ) if carrier_continuous and not third_party_triggered: return "attributable" return "contested" def require_causal_parent(parent: Span, child: Span) -> None: """ Strict mode: used by blame/cost rollups that refuse to charge a span to an instance without verified causal parentage. """ verdict = attribute_edge(parent, child) if verdict != "attributable": raise LineageAttributionError( f"edge {parent.span_id}->{child.span_id} is contested: " f"transport_parent={child.transport_parent}, " f"parent.origin_context_id={parent.origin_context_id}, " f"child.origin_context_id={child.origin_context_id}, " f"dedup_attributed_to={child.dedup_attributed_to}" ) ```