AI Development

You Approved It and the Agent Asked Again: Approval Is a State Machine, Not a Button

A human-in-the-loop approval that gets recorded, serialised, restored and then silently ignored is the most expensive bug shape in an agent system, because nothing errors. The same defect has been re-found at four different boundaries in one SDK this year. The fix is architectural: stop inferring which call an approval belongs to and write it down.

KAKabir AnandLead Developer
9 min read
Close-up of a worn brass ticket-punch validator on a dark counter with a single unpunched paper stub resting beside it

Someone taps Approve. The agent resumes. The tool never runs, and the same approval request arrives again a second later. Nothing is logged, nothing is thrown, nothing lands in your error tracker — because from the framework's point of view nothing went wrong. It looked for an approval matching the pending tool call, did not find one, and did the safe thing: it paused and asked again.

That is the worst possible failure mode for a permission gate. A gate that breaks loudly gets fixed on the first day. A gate that forgets decisions teaches your operators that the button is flaky, and they start double-tapping it — which is how you end up with the opposite bug.

This is not hypothetical, and it is not one careless bug. In the OpenAI Agents SDK for Python, an August 2026 report titled Tool approval is not honored on resume when Runner.run is given a context came with a deterministic reproduction: five context-bearing configurations, five failures, 100% of runs, while the context-free control passed every time. It raised no exception. The tool simply never executed and the agent re-interrupted. The fix shipped in v0.20.0 alongside several other approval and resume identity fixes — which is the detail that made us pay attention. If one release has to fix several of these at once, the bug is not in the code. It is in the contract.

The decision was bound to something that cannot be serialised

The documented API is fine, and worth stating precisely so it is clear the problem is somewhere else. You mark a tool with needs_approval — available on function_tool, Agent.as_tool, ShellTool and ApplyPatchTool, as either a boolean or an async function that decides per call. When the agent reaches that tool, the SDK records an approval interruption instead of executing it, and the run result hands you interruptions plus a resumable state. You call state.approve(interruption) or state.reject(interruption), then resume with Runner.run(agent, state). To survive a restart, you persist with state.to_json() and rehydrate with RunState.from_json(agent, blob).

Read that sequence again and notice that the human decision happens in the middle of it. In anything real, the pause and the resume are not the same process. The agent pauses on a worker, the state goes into Postgres, a person gets a Slack message twenty minutes later, and some other worker picks it up. The serialise-and-restore step is not an edge case for durability nerds. It is the normal path.

So what does approve() actually match against? The root-cause analysis on a later issue in the same repository spells it out. A pending Agent.as_tool() run is serialised with the tool's own agent as the root of its nested state. On approve(), the matching helper compares the two agents by object identity and returns false, so no nested state is found that owns the approval. The decision is recorded against nothing.

Object identity is precisely the one property of a Python object that is guaranteed not to survive to_json() and from_json(). Rebuilding from a blob creates new objects by definition. So the match works perfectly in a single-process demo, where the objects really are the same objects, and fails as soon as the state goes through storage — which is to say, as soon as you ship it.

The resume boundary — what crosses it and what does not

THE RESUME BOUNDARY — where a recorded approval stops being matchablethe pause and the resume are different processes in every real deployment01PAUSE · process Atool marked needs_approvalinterruption recordedtool NOT executedstate.to_json()03RESUME · process BRunState.from_json(agent, blob)→ brand new agent objectsstate.approve(interruption)Runner.run(agent, state)02THE STORE · a JSON blobcrosses: tool name, arguments,call id, agent NAME,RunState schema versiondoes NOT cross: the objectsON RESUME THE SDK MUST ANSWER ONE QUESTION:which agent owns this approval?duplicate agent names→ the wrong ownernested as_tool run→ no owner foundhook state changed→ wrong same-name agent
Every documented variant is the same question asked at a different boundary. Answer it by comparing object identity and the answer is always false after a round trip — at which point the approval is present, unmatched, and silently ignored.
Flat vector illustration of a filled shape on the left joined by a dashed line across a vertical divider to two identical empty outlines, the line forking and both forks ending in blunt dead-end caps
The decision is real on the left. On the right there are two candidates and no way to tell which one it belonged to.

Four boundaries, one question

What convinced us this was a design problem rather than a bug was watching it reappear. The context case was fixed in v0.20.0. Version 0.24.0 landed on 15 October 2026 with new RunState snapshots at schema 1.21, and its own fixes included preserving function-call aliases across restoration and preserving agent ownership across hook state changes. Issues filed against 0.24.0 were still finding new corners of the same defect.

  • Two agents with the same name— a nested approval is never applied after a JSON round trip when agent names repeat and the pending call belongs to the second one. A sibling issue reports RunState.from_json resuming the wrong same-name agent when hook state changes. A name is not an identifier, and in a graph assembled from reusable sub-agents, repeated names are the default, not the accident.
  • Approval raised inside an agent-as-tool — ToolContext.approve_tool() has been reported silently dropping the decision for a nested agent-as-tool approval, logged as a regression from an earlier fix. Delegation means the component that surfaces the interruption and the component that owns it are different objects at different depths.
  • Work that completed before the pause— one fix is titled, flatly, “preserve completed tool results when resuming approvals”. Another issue describes deferred items from the interrupted turn never being persisted, leaving an orphaned function_call_output in the session. An interrupted turn is usually a partially completed turn, and the half that already succeeded has to be preserved exactly.
  • Durable execution— a Temporal integration issue reports a RunState rebuilt from a string and resumed inside a workflow hanging on approvals after continue-as-new. Durable engines replay and re-enter; a contract that only holds within one continuous execution does not survive them.

One more is worth quoting because of what the error message admits. Filed against 0.24.0, a report of serialised approval checkpoints that cannot be resumed when the parent agent has an output guardrail and the approval came from an agent used as a tool. The failure is: "Cannot resume a serialized approval checkpoint with output guardrails because the current response boundary cannot be proven." Cannot be proven. The framework is telling you, in production, that it is trying to deduce a fact it was never given.

“An approval is not a message. It is a transition between two states that may not share a process, a memory space, or a clock.”

Bind the approval to a key you wrote down

The direction of the upstream fixes is the useful part, and we copied it rather than inventing something. The patch for the guardrail case introduces RunState schema 1.22, which records that a pending approval belongs to a nested run, and on restore verifies that the child actually owns the approval instead of independently re-deriving it. That is the whole lesson in one diff: stop inferring ownership, store it.

In our own gates we never let an approval reference a live object. It references a record, and the record is the contract. Everything in it has to be reconstructible from the blob alone.

lib/agent/approvals.ts
1type ApprovalRecord = {
2  schema: number; // ours, not the SDK's — we version this contract
3  callId: string; // the one thing that is already unique and stable
4  agentPath: string; // "triage/billing/refundAgent" — a path, never a name
5  toolName: string;
6  argsHash: string; // sha256 of canonicalised args
7  principal: string; // who decided, carried in the blob
8  policyVersion: string; // what they were shown when they decided
9  decision: "approved" | "rejected";
10};
11 
12export function resolve(pending: PendingCall, records: ApprovalRecord[]) {
13  const hit = records.find((r) =>
14    r.callId === pending.callId && r.agentPath === pending.agentPath);
15 
16  // an unmatched record is the bug. Never fall through to "ask again".
17  if (!hit && records.length > 0) throw new OrphanedApproval(pending, records);
18  if (hit && hit.argsHash !== hashArgs(pending.args)) throw new ArgumentsChanged(pending);
19  return hit ?? null; // null = genuinely undecided, which is a pause
20}

Two of those lines do most of the work. argsHash over canonicalised arguments means an approval authorises one invocation, not a tool — if the model retries the same tool with a different amount or a different recipient, that is a new decision, and the old record must not cover it. And agentPath instead of an agent name is what makes the record survive a graph where the same sub-agent appears twice.

The throw is the part people leave out, and it is the part that would have caught every issue described above on day one. If you hold approval records and none of them matches the pending call, you have exactly two possibilities: the human decided about something else, or your matching is broken. Both deserve a page. Neither deserves a silent re-prompt, which is the behaviour that let these bugs sit in production long enough to be filed by strangers.

Isometric technical illustration of labelled card-shaped layers seated into keyed notches in a slotted block, each card fitting only one orientation
A keyed slot cannot accept the wrong card. That is the whole design goal: make the wrong match impossible to express rather than unlikely to occur.

What we check before we ship an approval gate

We are not writing this from a position of having got it right first time. Our own approval gate — plain job queue, Telegram buttons, no agent SDK involved — shipped with two bugs from exactly this family, and both took live traffic to find.

The first: on approval, a job went back to pending carrying the expires_at it was given when it was created. A separate janitor job swept rows that were pending and past their expiry and marked them expired. So a human would approve something, and if they had taken longer than the original window to answer, the work would vanish — approved, swept, no error anywhere. The second was a race. The approval workflow marked the job done, and a worker step that was still in flight wrote it back to needs_approval afterwards, so every decided job of one class sat in needs_approval forever waiting for a decision that had already been made.

Neither is an agent bug. Both are the same bug as the SDK's: two components disagreeing about who owns a row's state after a decision, with no component responsible for noticing the disagreement. That is why the checklist below is framework-agnostic.

  • 1Test the round trip, not the pause— serialise, restore in a fresh process, approve, resume. A test that approves against the in-memory state proves only that identity comparison works on identical objects, which it always does. Run the same test with two sub-agents sharing a name.
  • 2An unmatched approval is an incident— records present, none matching, is a thrown error with both sides logged. Never a pause.
  • 3Re-extend every deadline on resume— a decision resets the clock. Anything that reaps stale work must not be able to reap something a human has already signed off.
  • 4One decision, one invocation— bind to a hash of canonicalised arguments and a call id. Changed arguments require a fresh approval, and a replayed approval must execute at most once.
  • 5Make the terminal state terminal— once a row is decided, no later-arriving step may write it back to awaiting-decision. Our fix was a single AND status = ’running’ in the query that parks a job; the principle is that only one component owns the transition.

Pin your SDK version and read the approval and resume entries in its changelog before you upgrade, because this contract is still moving — schema 1.21 in October, schema 1.22 in the fix queue at the time of writing. But do not treat that as the mitigation. The mitigation is that your gate holds its own record, matches on fields that exist in the blob, and shouts when the match fails. Then the next variant of this bug costs you an alert instead of an audit.

If you only change one thing this week, change the fall-through. Find the branch where your system has approvals it cannot match and asks the human again, and make it throw. You will learn more in a day than from any amount of reading about state machines.

Keep Reading

More from the blog

Track Record

The Engineering Partner You Can Build On

Reliable software takes an experienced team that owns delivery end to end. Here’s the track record behind ours.

Book a Free Consultation
01

11+

Years Building Custom Software

02

320+

Projects Delivered Across Web, Mobile & AI

03

85%

Repeat Client Rate

04

12+

Countries Served Worldwide

Trusted by startups and enterprises worldwide

Work With Us

Let’s create
with purpose

Share your goals, timeline, and challenges — we’ll respond with clarity and next steps.

Ambitious ideas deserve thoughtful execution. Start the conversation and let’s define what success looks like.

Team

Acetrum

Est. 2015

4.9/5

Trusted by
top brands

Services interested in:

By submitting, I confirm I’ve read and agree with Privacy and Cookie Policies.

Newsletter

Signals worth
paying attention

No recycled headlines — just the patterns we’re seeing across real client work, distilled into one read a month.

A curated digest of practical thinking and real-world brand perspectives monthly.

No spam. Unsubscribe anytime.