To get a human decision before an agent acts, the run can pause at the relevant step. The OpenAI Agents SDK offers a human-in-the-loop workflow that waits for a person to approve or reject sensitive tool calls. Calls that require approval appear as interruptions. Once a decision is made, the run resumes where it left off.
Choosing which calls require approval
In the OpenAI Agents SDK, setting a tool's needs_approval to True requests approval for every call. The same field can also accept an async function that decides whether approval is required on a per-call basis. The function receives the run context, the parsed tool parameters, and the tool call ID.
When a function-based approval rule cannot safely inspect the arguments, the SDK requires human approval. This covers missing, empty, or whitespace-only arguments and invalid JSON. It also covers valid JSON values that are objects only in the sense that the rule requires an actual JSON object, as well as nonstandard numeric constants. In these cases, the SDK skips the approval function.
needs_approval is available for function tools as well as Agent.as_tool, ShellTool, and ApplyPatchTool. Local MCP server types support approval through require_approval. For a hosted MCP server, require_approval can be set in the HostedMCPTool configuration.
For local ShellTool and ApplyPatchTool calls, approval is off by default because needs_approval starts at False. Defining an on_approval callback alone does not enable approval. The SDK runs the callback only for calls that require approval and have no existing decision.
Making a decision and resuming the run
When the model produces a tool call, the runner evaluates the approval rule for that call. If a decision is already stored in RunContextWrapper, the runner proceeds without asking again. If approval is required and no decision is recorded, the run pauses.
Pending requests appear as ToolApprovalItem entries in RunResult.interruptions or, for streaming runs, in RunResultStreaming.interruptions. These items include details such as agent.name, tool_name, and arguments. The workflow also covers requests that arise after a handoff or during a nested Agent.as_tool() run.
To apply a decision, convert the result to a RunState using result.to_state(). Then call state.approve(...) or state.reject(...) for the relevant item. Resume with the original top-level agent and that state using Runner.run(agent, state) or, for streaming, Runner.run_streamed(agent, state). The run can pause again if a subsequent call requires approval.
A nested agent can require approval at two points. Agent.as_tool(..., needs_approval=...) can require approval before the agent is invoked as a tool. Once the nested agent starts, its own tool calls can require approval as well. The nested interruption appears in the outer run. Apply the decision to the outer RunState and resume the original top-level run.
You can resolve pending decisions in batches. If you approve or reject some items and resume the run, the calls with decisions can proceed. Items still awaiting a decision remain in interruptions, and the run pauses again.
Scope of one-time and persistent decisions
In the OpenAI Agents SDK, a one-time approval applies only to the corresponding call ID. With always_approve=True or always_reject=True, the decision can be saved for future calls to the same tool identity. These decisions can carry over to separate runs as long as those runs reuse the RunContextWrapper that holds them.
RunState also stores persistent decisions. Those decisions are retained when the state is serialized and later restored. Passing only the same application context object to a new run creates a fresh wrapper. The context object alone does not carry approvals over.
For a function tool, a persistent decision is scoped to the agent requesting approval. Another agent's function tool needs its own decision even if it has the same name. For local ShellTool and ApplyPatchTool calls, persistent decisions are matched by tool type and name, regardless of the owning agent or executor.
This distinction matters during handoffs. If agents share approval state, a persistent shell approval granted to one agent can also apply to another agent's tool with the same type and name. When the SDK finds a match, it proceeds without asking again or reevaluating the target tool's needs_approval rule or on_approval callback. Persistent rejections are shared in the same way.