How to Add Human Approval to OpenAI Agents SDK Workflows
A practical JavaScript and Python guide to pause, approve and resume AI agent tool calls, with secure reviewer checks and duplicate-action protection.
Human approval is a control for an AI agent's **actions**, not a request to make its text sound more cautious. If an agent can send an email, modify a record, run a shell command, or initiate a payment, put an approval boundary immediately before the consequential tool executes. The OpenAI Agents SDK supports this pattern in both JavaScript and Python: an execution can pause, expose pending tool calls, accept an approve-or-reject decision, and resume.
This guide focuses on implementing that boundary safely. It complements prompt evaluation and general workflow planning: those help decide whether an AI response is useful, while approval controls whether an external action is allowed.
1. Decide which tools require approval
Start with the action's consequences, not the model's confidence. Reading public documentation may be safe to automate. Sending a message to a customer, deleting a CRM record, changing access permissions, or paying a supplier warrants a separate policy. Consider the destination, amount, data sensitivity, reversibility, and whether a person can inspect the exact proposed arguments.
OpenAI's guardrails and human review guide distinguishes automatic input/output/tool validation from human approval. Guardrails check conditions; approval explicitly authorizes a sensitive side effect. They are complementary, not interchangeable.
2. Pause the run before the tool executes
In the JavaScript Agents SDK, configure the tool's `needsApproval` policy. When a matching call is attempted, the SDK records an approval item and returns pending `interruptions` rather than executing that tool. Inspect the requested tool name and parsed arguments, then call `result.state.approve(interruption)` or `result.state.reject(interruption)`. Resume the original root agent using its updated state.
The Python SDK follows the same conceptual pause–review–resume pattern, with Python-specific names and state serialization methods. Consult the documentation for the installed SDK version rather than copying JavaScript signatures into Python.
An approval can surface from a nested agent or delegated tool. Review it at the outer run and resume the original top-level agent. Approval does not mean every later action is automatically permitted.
3. Show the reviewer an actionable decision
A useful approval request should identify the proposed operation, destination, exact relevant arguments, expected consequence, and any sensitive or irreversible effect. For a sales assistant, show the recipient, subject and final email body before sending. For a CRM updater, show the record ID and the proposed field changes. For a payment, show the merchant and amount.
Avoid a vague button labeled “Approve AI.” The person should authorize a specific tool call. Keep the default response as rejection when a reviewer is unavailable, unauthorized, or the request expires. If the arguments change, require a new decision rather than silently reusing an older approval.
4. Persist state for approvals that take hours
A person may respond long after the original HTTP request ends. The SDK supports serializing a paused `RunState` and restoring it later. The important security boundary is **where that state lives**. OpenAI's Python guidance warns that serialized state includes pending calls, arguments and decisions; deserialization alone does not authenticate the state or reviewer.
Store the complete snapshot in trusted server-side storage. Send the browser only an opaque approval ID and the information the reviewer is permitted to see. When a decision arrives, authenticate the person, verify that they are authorized for this run, match the decision to server-owned pending calls, atomically consume the approval request, and only then resume execution. Do not accept a client-supplied replacement snapshot as authoritative.
5. Prevent duplicate actions after a crash
An approved tool can perform an external action before the server successfully saves the new state. If an old snapshot is resumed, that action may run again. Human approval therefore **does not guarantee exactly-once execution**.
For consequential actions, assign a stable idempotency key to the logical operation. Where the destination supports it, enforce that key atomically so a retry cannot create a second payment, email or CRM mutation. Otherwise reconcile the destination's existing state before retrying. Record tool-call IDs, approval decisions, outcomes and errors without exposing unnecessary private information.
6. Test both the happy path and failure path
Before deploying, test approval, rejection, delayed approval, missing reviewer permissions, changed arguments, expired requests, simultaneous decisions, server restart, and crash-after-side-effect recovery. Verify that a rejected call does not execute and that a resumed run does not unintentionally repeat a completed action.
For sensitive workflows, retain deterministic argument validation even after human approval. The reviewer might miss an invalid destination, and the model might retry. The SDK's approval mechanism is one layer of a larger authorization and operational-safety design.
Questions people ask
Can an OpenAI agent wait for approval without keeping the server running?
Yes. The Agents SDK supports serializing a paused run and restoring it when a decision arrives. Keep the state in trusted server-controlled storage, then authenticate and authorize the reviewer before applying the decision. The JavaScript and Python SDKs expose related but language-specific serialization APIs. This is a resume mechanism, not a hosted approval inbox supplied automatically by every application.
Is a tool guardrail the same as human approval?
No. A guardrail validates inputs, outputs or tool behavior against rules; human approval explicitly authorizes a proposed action. Use deterministic checks for required fields, allowed destinations and prohibited content, then ask a person to approve high-impact side effects. A successful guardrail check should not silently replace the required human decision, and an approval should not bypass independent validation.
Does approving a tool call guarantee it happens only once?
No. Approval allows execution but does not provide exactly-once delivery. A crash after an external side effect and before saving the resumed state can cause a retry to repeat the action. Use a stable idempotency key supported by the destination, or reconcile the external action before replaying. This is especially important for payments, customer messages and irreversible data changes.
Can a reviewer approve a nested agent's tool call?
Yes. The JavaScript SDK documents that approval interruptions raised by nested `agent.asTool()` executions surface on the outer run. Review the pending call using the outer run state and resume the original top-level agent. Approval at one layer does not automatically authorize all nested tool actions; separate approval boundaries can still be triggered later.
Bottom line
Use human approval at the boundary where an AI suggestion becomes a real-world side effect. Make the requested action inspectable, keep approval state server-owned, authenticate reviewers, and protect retries with idempotency. A reliable workflow needs all four controls, not just a prompt that tells the agent to “ask first.”