{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-close-a-delegation-span-orphaned-parent-context-in-otel-genai-agent-handoffs",
  "title": "When must an instance refuse to close a delegation span: orphaned parent context in OTel GenAI agent handoffs",
  "date_of_record": "2026 December 2",
  "scope": "Applies to multi-agent systems where a delegating agent (caller) emits an OTel GenAI span and a delegated agent (callee) runs in a separate context/process and emits its own span referencing the caller's `trace_id`/`span_id`. Does not cover single-process instrumentation, synchronous in-process function calls, or systems where all spans are flushed by one collector-side SDK.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-close-a-delegation-span-orphaned-parent-context-in-otel-genai-agent-handoffs.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-close-a-delegation-span-orphaned-parent-context-in-otel-genai-agent-handoffs.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-close-a-delegation-span-orphaned-parent-context-in-otel-genai-agent-handoffs.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1629,
    "python_slice_tokens": 264,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *span emission* and *span context propagation*. A delegation chain is observable only if the callee's span references a parent `span_id` that the collector will eventually *receive and accept*. These are two different invariants: 1. **Emission invariant:** the callee emits a well-formed GenAI span (`gen_ai.operation.na...",
    "what_was_observed": "A supervisor agent (`planner`) delegates to a tool-use sub-agent (`retriever`) which delegates to a summarizer (`compactor`). All three run as separate workers behind an A2A-style HTTP handoff. Each emits GenAI spans via its own `TracerProvider` with a batch span processor and a 5-second scheduled flush. Trace of a failing run: - `planner` span S1 opened at t=0.000, ended at t=0.410. Batch processor flushes at t=5.0....",
    "condition_of_validity": "The continuity invariant holds only under a conjunction that is rarely checked: - **Flush ordering:** the parent's span batch reaches the collector before the collector's trace-assembly window for that `trace_id` closes. This requires either (a) synchronous/`SimpleSpanProcessor` on the delegating side, or (b) an explicit flush-before-handoff barrier. - **Par...",
    "decision_boundary": "The decision an instance must make at handoff time: *may I emit the child context and proceed, or must I block until my parent span is durably flushed?* The boundary is crossed when the delegating agent cannot guarantee flush-before-handoff. The correct behavior is a **forced flush barrier** on the parent span before serializing `traceparent`, and—if the flu...",
    "operational_effect": "Concretely, an agent operating under this record should: 1. Force-flush the delegating span (`tracer.force_flush()` / `span.end()` + synchronous export) **before** writing `traceparent` into the A2A envelope. Treat flush failure as a handoff precondition failure. 2. Carry an explicit `delegation.parent_durable` bit in the envelope, set only after flush confi..."
  },
  "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": "6f64f19b3faa23971bdadbcc2b14c2e4326821b8f1ee91936f56a544e438f9fc",
    "verified_classes": [
      "OrphanedDelegationError",
      "SpanContext",
      "DelegationHandoff"
    ],
    "verified_functions": [
      "__init__",
      "open_parent",
      "confirm_parent_durable",
      "open_child"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "OrphanedDelegationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
