# Under what conditions must an instance treat a planning span's `next.step` attribute as non-authoritative once a human-in-the-loop approval span has closed **Date of Record:** 2026 November 25 **Scope:** Applies to instrumented agent runtimes that emit OpenTelemetry-style semantic conventions for planning spans (`gen_ai.agent.plan`), sub-agent delegation spans (`gen_ai.agent.delegate`), and human approval spans (`gen_ai.agent.approval`), where a resumed instance reconstructs intent from span attributes rather than from live in-memory state. Does not apply to single-process agents that never serialize planning state across a trace boundary, nor to synchronous approval flows where the approving human is co-located with the executing loop. ## Core Distinction A planning span records *what the agent intended at emission time*. An approval span records *what a human authorized at some later wall-clock instant*. These are two different epistemic objects with two different truth conditions, and the semantic conventions for agent planning spans quietly encourage treating them as one object by attaching a `gen_ai.agent.plan.next.step` attribute to the plan span and a `gen_ai.agent.approval.decision` attribute to the approval span. The non-obvious boundary: **a closed approval span does not retroactively rewrite the plan span's `next.step`.** When an agent resumes from a trace—after a context-window eviction, a process restart, or a handoff to a fresh instance—it commonly reconstructs its next action by reading the most recent plan span's `next.step`. But if the human modified the plan during approval (approved with edits, approved a subset, or approved a *different* next step than the one the planner proposed), the authoritative intent lives in the approval span's `decision` and any `gen_ai.agent.approval.amended_plan` payload, not in the plan span. The plan span is immutable historical fact; the approval span is the governing constraint. Reading the plan span after approval closure is a **stale-intent read**, and it silently re-executes the pre-approval proposal. This is not a schema mismatch and not a lost message. Every span is present, well-formed, and correctly ordered. The failure is that two spans both plausibly answer "what should I do next," and the convention does not mark which one wins. ## What Was Observed A delegated research agent emitted the following span sequence during a task that required human sign-off before a destructive tool call: 1. `gen_ai.agent.plan` span closes with `gen_ai.agent.plan.next.step = "purge_staging_cache"` and `gen_ai.agent.plan.confidence = 0.81`. 2. `gen_ai.agent.approval` span opens, blocks for 40 minutes, and closes with `gen_ai.agent.approval.decision = "approved_with_edits"` and `gen_ai.agent.approval.amended_plan.next.step = "purge_staging_cache_dry_run"`. The human explicitly downgraded the destructive step to a dry run. 3. The process was preempted mid-approval-wait; on resume, the orchestrator rebuilt agent state from the trace. On resume, the reconstruction logic selected the plan span (it carried the `next.step` attribute the resumption code was written against) and executed `purge_staging_cache`. The dry-run amendment was present in the trace, correctly attributed, and ignored. No error was raised; the delegation span reported `status = OK`. The trace was internally consistent. The failure was purely in the read path: the resumption code had no rule for "approval span closed after plan span → approval span supersedes." A second observation sharpened the mechanism. In a variant run, the human approved with *no* edits (`decision = "approved"`, no `amended_plan`). Here reading `next.step` from the plan span happened to be correct—which is precisely why the bug survived testing. The failure only manifests on the `approved_with_edits` and `approved_subset` branches, and only when resumption occurs after approval closure. The happy path trains the reconstruction logic to trust the plan span. ## Condition of Validity The stale-intent read is *valid to ignore* — i.e., reading `next.step` from the plan span is safe — only when **all** of the following hold: - No `gen_ai.agent.approval` span with the same `gen_ai.agent.plan.id` correlation key has closed with a decision other than plain `approved`. - The plan span's end timestamp precedes any approval span's start timestamp for that plan id (a plan emitted *after* approval reflects post-approval intent and is authoritative). - The resuming instance can prove it is reading the trace tail, not a mid-trace snapshot taken before approval closure. If any condition fails, `next.step` on the plan span is **non-authoritative** and the instance must resolve intent from the approval span. The invariant to encode: *for a given plan correlation key, the governing next-step is the `next.step` of the latest plan span that either has no subsequent approval span or whose subsequent approval span closed with `approved` and no amendment.* The subtle part is the third condition. A resuming instance that reads a trace snapshot captured *during* the 40-minute approval block will see an open approval span and a plan span with `next.step` set—and may reasonably conclude "approval pending, I should wait." But if it instead concludes "no closed approval yet, fall back to plan," it executes the unapproved destructive step. Open approval spans are a *block*, not a *fallback-to-plan* signal. The convention needs an explicit `gen_ai.agent.approval.state ∈ {open, closed, abandoned}` so that `open` is distinguishable from "span absent." ## Decision Boundary The decision the resuming instance must make is not "which span is newer" but "which span is *authoritative for intent*." These diverge because plan spans and approval spans are emitted by different producers (planner model vs. approval gateway) with independent clocks and independent completion semantics. Formalize the boundary as a precedence rule over the correlated span set `S(plan_id)`: - Let `P*` = the plan span in `S` with the greatest end timestamp. - Let `A*` = the approval span in `S` with the greatest end timestamp, if any. - If `A*` exists and `A*.decision ≠ "approved"`, the governing step is `A*.amended_plan.next.step` if present, else the delegation must be **halted** (the human neither approved the proposed step nor supplied a replacement). - If `A*` exists and `A*.decision == "approved"`, the governing step is `P*.next.step`. - If `A*` is open (state `open`), the instance must **block**, never fall through to `P*`. - If no `A*` exists and `P*` is the trace tail, `P*.next.step` is authoritative. The failure mode this prevents is the *silent fall-through*: any code path where "approval not found" or "approval not closed" resolves to the plan span's proposal. That path converts a pending or amended human decision into autonomous execution of the original proposal—the exact inversion of the human-in-the-loop guarantee. A second boundary governs sub-agent delegation. When a plan span delegates to a sub-agent (`gen_ai.agent.delegate`), the sub-agent inherits the *approved* intent, not the *proposed* intent. If the parent approved `purge_staging_cache_dry_run`, the delegate span's `gen_ai.agent.delegate.task` must be derived from the approval span's amended plan. A delegate span whose task text matches the pre-amendment plan is a detectable signal that the stale-intent read already occurred upstream—it should be treated as a poisoned delegation and rejected at the sub-agent boundary, not executed and audited later. ## Operational Effect The practical consequence is that trace-based resumption of agent state is only sound if the resumption logic is *approval-aware*, not merely *span-aware*. Teams that build resumption against "read the latest plan span" will pass every test that exercises the `approved` branch and fail silently on every `approved_with_edits` branch—and the failure is invisible in telemetry because the executed step is a valid, well-formed tool call that the plan legitimately proposed. Mitigations that actually bound the failure: 1. **Correlation-keyed precedence resolution.** Resumption must group spans by `gen_ai.agent.plan.id` and apply the precedence rule above, never "latest span wins." 2. **Explicit approval state.** Emit `gen_ai.agent.approval.state` with `open`/`closed`/`abandoned` so absence is distinguishable from pending. Treat `open` as a hard block, not a fallback trigger. 3. **Amendment propagation check at delegation.** Sub-agent delegate spans must carry the `approval.id` they derive intent from; a delegate span with no approval lineage on an approval-gated plan is rejected before tool execution. 4. **Fail-closed on ambiguity.** If the precedence rule cannot resolve a governing step (missing amended plan on a non-`approved` decision, clock skew making `P*`/`A*` ordering indeterminate), halt and re-request approval rather than defaulting to the plan. The invariant, stated once: *a plan span's `next.step` is authoritative only in the absence of a subsequent non-`approved` or open approval span for the same plan id; every other case resolves through the approval span or halts.* ```python from dataclasses import dataclass from typing import Optional class StaleIntentReadError(RuntimeError): """Raised when resumption would execute a plan step that a closed approval span has amended or that an open approval span still gates.""" @dataclass class PlanSpan: plan_id: str next_step: str end_ts: float @dataclass class ApprovalSpan: plan_id: str state: str # "open" | "closed" | "abandoned" decision: Optional[str] # "approved" | "approved_with_edits" | "approved_subset" | "rejected" amended_next_step: Optional[str] end_ts: float def resolve_governing_step( plan: PlanSpan, approval: Optional[ApprovalSpan], ) -> str: """Apply approval-aware precedence. Returns the step the instance is authorized to execute, or raises rather than falling through to the plan's unapproved proposal.""" if approval is None: # No approval span for this plan id: plan is authoritative only if # the caller has proven it is reading the trace tail. We cannot prove # that here, so require the caller to have passed a tail-verified plan. return plan.next_step if approval.plan_id != plan.plan_id: raise StaleIntentReadError( f"approval {approval.plan_id!r} does not correlate to plan {plan.plan_id!r}" ) if approval.state == "open": # Pending human decision must block, never fall through to plan. raise StaleIntentReadError( f"plan {plan.plan_id!r} has an open approval span; " f"executing proposed step {plan.next_step!r} would bypass human-in-the-loop" ) if approval.state == "abandoned": raise StaleIntentReadError( f"approval for plan {plan.plan_id!r} was abandoned; re-request approval" ) if approval.decision == "approved": return plan.next_step if approval.decision in ("approved_with_edits", "approved_subset"): if approval.amended_next_step is None: raise StaleIntentReadError( f"approval for plan {plan.plan_id!r} is {approval.decision!r} " f"but carries no amended_next_step; ambiguity must fail closed" ) return approval.amended_next_step if approval.decision == "rejected": raise StaleIntentReadError( f"plan {plan.plan_id!r} was rejected by human approver; halt delegation" ) raise StaleIntentReadError( f"unrecognized approval decision {approval.decision!r} for plan {plan.plan_id!r}" ) def resume_delegation(plan: PlanSpan, approval: Optional[ApprovalSpan]) -> str: step = resolve_governing_step(plan, approval) if approval is not None and approval.state == "closed" and approval.decision != "approved": if step == plan.next_step: # Defensive: precedence returned the proposed step despite amendment. raise StaleIntentReadError( f"resolved step {step!r} equals pre-amendment proposal for " f"plan {plan.plan_id!r}; stale-intent read detected" ) return step ```