# Under what conditions must an instance reject a parent-child span link when a nested agent-to-agent trace crosses a GenAI semantic-convention boundary **Date of Record:** 2026 December 1 **Scope:** Applies to any agent runtime that emits OpenTelemetry spans annotated with the GenAI semantic conventions (`gen_ai.*`) and that links child agent invocations to a parent via `traceparent`/`tracestate` plus a semantic-convention-versioned attribute set. Does not apply to single-process, single-agent traces where parent and child share one SDK and one `gen_ai` schema version. ## Core Distinction A trace identifier is a transport-level continuity token. A GenAI semantic-convention span link is a *semantic* claim: it asserts that the child span's `gen_ai.operation.name`, `gen_ai.provider.name`, `gen_ai.request.model`, and token-accounting attributes are commensurable with the parent's, such that an aggregator summing `gen_ai.usage.input_tokens` across the trace produces a meaningful total. These two properties decouple the moment a nested agent delegates to a peer running a different `gen_ai` schema revision. The span context still propagates (W3C `traceparent` is version-agnostic), so the trace *looks* continuous. But the semantic link is a lie: the child's attribute namespace may use `gen_ai.usage.prompt_tokens` where the parent uses `gen_ai.usage.input_tokens`, or may report `gen_ai.operation.name=chat` where the parent reports `invoke_agent`. The failure mode is not a broken trace; it is a *silently mis-aggregated* one. ## What Was Observed A three-tier delegation chain: orchestrator (SDK schema v1.27, `gen_ai.usage.input_tokens`) → planner sub-agent (schema v1.29, `gen_ai.usage.input_tokens` but adds `gen_ai.usage.cache_read.input_tokens` as a *sibling* rather than a sub-key) → executor sub-agent (vendor-forked schema, `gen_ai.usage.prompt_tokens`). The executor's span correctly carried `traceparent` pointing at the planner's span ID, and the planner's span pointed at the orchestrator's. The trace assembled into a well-formed tree with correct parentage and timing. The defect surfaced only in the accounting layer. The orchestrator's post-run verifier summed `gen_ai.usage.input_tokens` across all spans it considered descendants. Because the executor emitted `prompt_tokens`, its ~41k tokens were excluded from the sum. The verifier's budget invariant (`sum(descendant input_tokens) <= budget`) therefore *passed* while actual consumption exceeded budget by 38%. The run was marked compliant and a follow-on batch was scheduled against the same budget, compounding the overrun across four subsequent runs before a human noticed the provider bill diverged from the internal ledger. A second, subtler observation: when the planner's cache-read tokens were counted as a sibling attribute, the verifier double-counted them in one code path (summing both `input_tokens` and `cache_read.input_tokens`) and under-counted in another (treating `cache_read` as already included). Two verifiers, reading the same spans, disagreed on total by 12%. Neither raised an error; both reported "within budget." ## Condition of Validity The invariant that must hold for a span link to be semantically valid is: > For every child span linked to a parent, the child's `gen_ai` attribute keys that the parent's accounting logic reads must exist in the child's namespace, under the same key path, with the same unit and the same inclusion semantics (whether a token class is a sub-key or a sibling). This condition is *not* enforced by the W3C trace context, which carries no schema identity. It is *partially* enforced by the `gen_ai` semantic conventions only within a single schema version. Across versions, the conventions document deprecations and renames but provide no runtime negotiation signal on the wire. The `tracestate` header is the only available carrier for schema identity, and only if the emitter deliberately writes a vendor key such as `genai=1.29` into it. The condition therefore holds only when one of three things is true: (a) all participants in the trace are pinned to one `gen_ai` schema version; (b) a schema-version key is propagated in `tracestate` and every participant validates it before linking; or (c) the parent's accounting logic reads an attribute set that is *version-invariant by contract* (e.g., only `gen_ai.operation.name`, which has been stable, and never token attributes). Option (c) is the only one that survives uncoordinated third-party agents, and it means the parent cannot do token accounting from linked child spans at all—it must request a signed usage receipt out-of-band. ## Decision Boundary An instance must **reject** the parent-child link—emit the child span with a `span.kind=INTERNAL` orphan marker and a `gen_ai.link.rejected` event rather than a parent reference—when any of the following is true: 1. The child's `tracestate` carries a `genai` schema version that differs from the parent's, *and* the parent's accounting logic reads any `gen_ai.usage.*` attribute. (Token accounting is the load-bearing case; operation-name-only consumers may proceed.) 2. The child's `tracestate` carries no `genai` key at all *and* the child is a third-party or vendor-forked agent whose schema cannot be attested. Absence of attestation is not evidence of compatibility. 3. The child reports a token class (e.g., cache-read, reasoning) that the parent's schema version does not define, *and* the parent's budget invariant depends on total-token completeness. A partial sum that omits a defined token class is worse than no sum, because it passes silently. An instance may **accept** the link with a downgraded confidence marker when the schema versions differ but the parent reads only version-invariant attributes, or when the child provides an out-of-band usage receipt whose signature the parent verifies. The downgrade must be recorded on the parent span as `gen_ai.link.confidence=partial` so downstream aggregators do not treat the sum as complete. ## Operational Effect Enforcing the rejection boundary converts a silent accounting failure into a loud, localized one. The orphaned child span still appears in the trace (preserving debuggability), but the parent's budget verifier now sees an explicit gap rather than a plausible-looking sum, and must either fetch a receipt or fail the run. In the observed chain, adding the `tracestate` schema key and the rejection rule caused the executor's 41k tokens to surface as an *accounting gap* on the first run, halting the batch before the compounding overrun. The cost is a small increase in orphaned spans and a requirement that every agent runtime stamp its `gen_ai` schema version into `tracestate`—a one-line change per SDK, but one that must be made *before* the first cross-version delegation, because the failure is retroactively invisible in already-collected traces. ```python from dataclasses import dataclass from typing import Optional class SpanLinkRejected(RuntimeError): """Raised when a parent-child GenAI span link cannot be semantically validated.""" @dataclass(frozen=True) class GenAISpanContext: span_id: str genai_schema_version: Optional[str] # from tracestate key "genai"; None if absent reads_token_attrs: bool # does parent accounting read gen_ai.usage.* ? attested: bool # third-party schema attested out-of-band? # Attributes stable across all known gen_ai schema revisions; safe to read cross-version. VERSION_INVARIANT_KEYS = frozenset({"gen_ai.operation.name", "gen_ai.provider.name"}) def validate_link(parent: GenAISpanContext, child: GenAISpanContext) -> str: """Return link confidence: 'full', 'partial', or raise SpanLinkRejected.""" if child.genai_schema_version == parent.genai_schema_version and child.genai_schema_version: return "full" if not child.genai_schema_version: if not child.attested: raise SpanLinkRejected( f"child {child.span_id} carries no genai schema key in tracestate " f"and is unattested; parent {parent.span_id} cannot assume commensurability" ) return "partial" # Schema versions differ. if not parent.reads_token_attrs: # Parent only reads version-invariant attributes; downgrade is safe. return "partial" raise SpanLinkRejected( f"schema mismatch: parent {parent.span_id}@{parent.genai_schema_version} " f"reads gen_ai.usage.* but child {child.span_id}@{child.genai_schema_version} " f"may use a different token key path; aggregated sum would be silently incomplete" ) def link_or_orphan(parent: GenAISpanContext, child: GenAISpanContext) -> str: try: return validate_link(parent, child) except SpanLinkRejected as exc: # Emit child as INTERNAL orphan with gen_ai.link.rejected event. return f"orphaned: {exc}" ```