Skip to content
Back to log

Human approval for agent actions

Chainabit's Chao · · 7 min read

In short

Human approval lets an agent pause at a specific tool call and wait for a decision. Explore how approval workflows operate and where their limits lie through examples from the OpenAI Agents SDK, LangGraph, and Chainabit CLI.

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.

Turn this insight into action.

Use the mobile app to continue with guided workflows.

OpenAI recommends using one-time decisions when executors or editors have different permissions. Call state.approve(interruption) or state.reject(interruption) and leave the persistent decision options at their default False values. To request a human decision for every new local shell or file-editing call, set needs_approval=True and leave on_approval unset. Any existing persistent decision stays in place after a one-time decision.

For hosted MCP requests, a persistent decision is keyed by the combination of server_label and the tool name. A persistent approval for a tool on one hosted MCP server applies only to that server, even if another server has a tool with the same name. The SDK saves a persistent decision only if both identity fields are populated in the request.

Pausing before an action with LangGraph

LangGraph uses interrupt() to pause a graph run and wait for external input. When the call is made inside a node, the persistence layer saves the graph state. The run waits until it is resumed with a response.

interrupt() takes a JSON-serializable value and exposes it to the caller. In an approval workflow, that value can contain the details of the action under review. LangGraph lists pausing for approval before a critical API call or database change as an example use case.

To resume a paused graph, invoke it again and pass the response in Command(resume=...). That value becomes the return value of the interrupt() call inside the node. Resume with the same thread_id used when the interruption occurred. The checkpointer uses this ID to determine which state to load.

In LangGraph's approval example, the response routes the run to either the proceed or cancel node. The same mechanism can let a person review and modify an LLM output or a tool call. Placing interrupt() directly inside a tool function lets the tool call pause before it executes.

response_schema defines the input expected when the graph resumes. LangGraph converts a Pydantic model, TypedDict, or dataclass into JSON Schema and exposes it on the interruption. With a schema in place, invalid input triggers a validation error. A corrected response can be submitted using the same thread_id.

What details appear on the review screen?

When Chao wants to edit a file in Chainabit CLI, the approval card shows a diff between the current file and the proposed version before you decide. The card shows added and removed lines along with line numbers. If the file is too large, unreadable, or in a format other than plain text, the diff may be unavailable. The card explains why and still asks for a decision.

The card offers Deny, Allow once, and Always allow this file. The last option applies only to that file in that folder. Later edits to the same file proceed without another prompt. Other files, deletions, and other types of operations still prompt for approval.

In Chainabit CLI's Ask before edits mode, local tools can read files and every change requires approval. In Plan mode, local tools have read-only access to files. In Auto approve mode, Chao can edit files in trusted folders and run routine programs inside the sandbox without asking. Security and permission rules still apply.

The /permissions panel groups capabilities. Each row shows the decision currently in effect and the layer that controls it. If a setting cannot be changed from the panel, its row is marked locked and explains why. A change that relaxes a rule is shown for approval before it takes effect.

Limits of approval

According to the OpenAI Agents SDK, approval lets a tool call run, but the call can execute more than once. If a tool performs an external action and the process stops before the current run state is saved, resuming from an older approved snapshot can run the tool again.

A serialized RunState contains pending calls, tool arguments, and approval decisions. When restoring state, the SDK does not authenticate the snapshot or the person who submitted it. For browser or mobile approval interfaces, OpenAI recommends keeping the full snapshot in server-side storage controlled by the application and sending reviewers only the tool details and decision identifiers they are authorized to see.

In Chainabit CLI, access to another account or workspace requires separate authorization. Security rules, the permission mode, and the sandbox continue to govern operations in trusted folders. Revoking trust leaves completed work in place. A program detached from the sandbox session can also continue running until it exits.

Ready to start?

Download the app and continue from your phone.

End of Entry