Skip to content
Blog
October 27, 2026Architecture8 min readUpdated November 3, 2026

How to add human approval to AI agent tool calls: LangGraph, OpenAI Agents SDK, AI SDK and MCP compared

Pause the tool call before it runs, show the arguments to a person, and run it only on an explicit approve. LangGraph, the OpenAI Agents SDK and the AI SDK all ship a pause-and-resume mechanism; they differ on editing arguments, persistence, and what happens when nobody answers.

byPleach maintainers

Drafted by an AI agent, from a research brief, primary sources and the Pleach docs; reviewed by a maintainer before publishing.

No @pleach/* package is on npm yet. Each name holds a 0.0.1 placeholder until its first release, so the code here describes the source, not an install that works today. Package status

To add human approval to an agent's tool calls, pause the call before it executes, show the tool name and arguments to a person, and run it only on an explicit approve. LangGraph, the OpenAI Agents SDK and the AI SDK each ship a pause-and-resume mechanism for this. The Model Context Protocol says a human SHOULD be able to deny tool invocations, and leaves the prompt to the host application. The frameworks differ on four things: whether you can edit the arguments, how the pause survives a restart, who may answer, and what happens when nobody does.

The approval record also feeds later review; see reconstructing an agent decision for audit trail review and adding an audit ledger without rewriting your agent loop.

PropertyLangGraph / LangChainOpenAI Agents SDK (JS)AI SDKMCP spec (2025-06-18)
Mechanisminterrupt() in a node; HumanInTheLoopMiddleware with interrupt_onneedsApproval on a tool; pending items in result.interruptionstoolApproval on generateText / streamText / ToolLoopAgentHost prompts the user; servers can use elicitation/create
Before or after executionBefore (pause anywhere in a node)BeforeBeforeBefore ("deny tool invocations")
Reviewer decisionsapprove, edit, reject, respondapprove / reject; sticky alwaysApprove / alwaysReject; reject message for the modelapproved: true or false, optional reasonElicitation: accept, decline, cancel
Resume across restartsCheckpointer plus thread_idSerialize RunState, restore with RunState.fromStringApproval responses travel in the messages arrayHost application's design

These are not like-for-like. MCP is a wire protocol between a host and a tool server, while the other three are libraries that run the agent loop. Read the MCP column as the guidance a host is expected to honor, not as a runtime feature.

Why does an agent tool call need human approval?

A tool call is the point where an agent's output turns into an action, and OWASP lists ungated actions as a top-10 risk. OWASP LLM06:2025 Excessive Agency describes the vulnerability as one that "enables damaging actions to be performed in response to unexpected, ambiguous or manipulated outputs from an LLM."

OWASP names three root causes: excessive functionality, excessive permissions and excessive autonomy. Approval addresses the third. The mitigation titled "Require user approval" reads: "Utilise human-in-the-loop control to require a human to approve high-impact actions before they are taken."

The MCP tools specification makes the same point for tool servers. It says "there SHOULD always be a human in the loop with the ability to deny tool invocations." Applications SHOULD "present confirmation prompts to the user for operations." In its security considerations, clients SHOULD "show tool inputs to the user before calling the server, to avoid malicious or accidental data exfiltration."

Approval is one control among several. OWASP also lists minimizing extensions, permissions and functionality. A gate doesn't make a dangerous tool safe; it puts a decision in front of someone who can see the arguments.

Should approval happen before or after the tool runs?

Approve before execution whenever the call has side effects, because a review after it runs can't undo them. Every framework in the table pauses before the call. LangGraph's docs describe the pattern as "Pause before executing tool calls to review and edit the tool call before execution."

A review after execution still has a use. Some calls are harmless to run but risky to read: a database query, a file read, a search over private data. Holding the result until a person approves it keeps that output away from the model. The cost is that the side effect, if any, already happened.

The options a reviewer gets also differ by framework:

  • LangChain's human-in-the-loop middleware lists approve, edit, reject and respond. An edit will "Modify the tool arguments before execution," and the docs advise making those changes "conservatively."
  • The OpenAI Agents SDK resolves each item with result.state.approve(interruption) or result.state.reject(interruption). { alwaysApprove: true } or { alwaysReject: true } makes the decision stick for the rest of the run. A reject can carry { message: '...' }, the text the model reads for that call.
  • The AI SDK sends a tool-approval-response with approved: true or false and an optional reason. On a deny, the reason goes into the execution-denied result "so the model can see why the tool call was not executed."

The AI SDK also lets a function decide per call. A per-tool toolApproval function receives the tool input and can return 'user-approval' only when, for example, amount > 1000. The older needsApproval property on tool() is deprecated in favor of toolApproval.

How does an approval survive a restart?

The pause has to be stored somewhere outside the process, because a person may answer minutes or days later. Each library stores it differently.

LangGraph stores it in a checkpointer. The interrupts guide lists "A checkpointer to persist the graph state (use a durable checkpointer in production)" as a prerequisite. "thread_id is your pointer": reusing it resumes the same checkpoint, and the value passed to Command(resume=...) "becomes the return value of the interrupt call."

LangGraph has one behavior to plan for. On resume, "the runtime restarts the entire node from the beginning," so code before the interrupt() call runs again. Side effects placed before the interrupt in the same node will repeat.

The OpenAI Agents SDK serializes the run. You save result.state.toString() or JSON.stringify(result.state), then restore it with RunState.fromString(agent, serializedState). The guide says the flow "is designed to be interruptible for longer periods of time without keeping your server running."

The AI SDK carries approval in the conversation. You push the tool-approval-response onto the messages as a tool message and call generateText or streamText again. Persistence is whatever you do with that messages array. For the related problem of a resent request running a turn twice, see re-sending a chat message without running the turn twice.

Who is allowed to approve, and how should an unanswered request end?

The person who may approve is whoever your application authenticates as the owner of the session. MCP's guidance is written in terms of "the user" and the host's UI. In the libraries, your code submits the decision, so your request handler is where the decision gets bound to an authenticated caller and a session.

A pending approval stays pending until something resumes it. LangGraph's guide says the "Graph waits indefinitely until you resume execution with a response." The OpenAI Agents SDK's serialized run state lets that wait outlast the process. MCP's tools spec tells clients to "implement timeouts for tool calls," which governs execution. How long a human has to answer is a policy you set.

MCP elicitation is the closest thing to a standard vocabulary for an unanswered prompt. It defines three actions: accept, decline for an explicit no, and cancel when the user "dismissed without making an explicit choice." Keeping "said no" apart from "never answered" matters later, when someone asks who was accountable for a call. Elicitation also says servers "MUST NOT use elicitation to request sensitive information."

Should an approval gate fail open or fail closed?

Fail closed: if the approval can't be put to a person, the call should not run. OWASP's mitigation asks for approval of high-impact actions "before they are taken," which a fail-open gate breaks on every error path.

In LangGraph and the OpenAI Agents SDK, a paused call executes only when something resumes it with a decision. Apply the same default to the code around the pause: when a decision can't be obtained, treat it as "no".

When to use each

  • You run a LangGraph graph and need edits: use HumanInTheLoopMiddleware with interrupt_on, and a durable checkpointer.
  • You need a long wait without a running server: the OpenAI Agents SDK's serialized RunState is designed for that.
  • You're on the AI SDK and want rule-based gating: a toolApproval function that returns 'user-approval' only above a threshold.
  • You build an MCP host: show the tool inputs and a confirmation prompt before tools/call, as the spec's SHOULDs describe.
  • You need to prove who approved and why a gate ended: bind each decision to an authenticated actor and record an explicit unanswered outcome.

How Pleach does it

Pleach gates tool calls in two places. interruptBefore stops a named tool call before it runs. interruptAfter lets the call run, then holds its result for review. Both are production gates, and both fail closed.

import { SessionRuntime } from "@pleach/core";

const runtime = new SessionRuntime({
  storage: supabaseAdapter,
  userId:  "user_123",
  interrupt: {
    // Pause BEFORE these tools dispatch, for approval:
    interruptBefore: ["delete_file", "send_email", "execute_sql"],
    // Pause AFTER these tools complete, to review the result:
    interruptAfter: ["run_migration"],
    // Or gate dynamically on the tool call itself:
    interruptOn: (toolCall) => toolCall.name.startsWith("prod_"),
  },
});

The gated call waits inside the turn. The pause doesn't unwind the stack, and the call isn't re-run when the decision arrives. The runtime emits a PendingInterrupt to the consumer.

Before and after

IntentApprovalDecisionBefore-pauseAfter-pause
Approve{ approved: true }The call runs with its original argumentsThe result reaches the model unchanged
Approve with edits{ approved: true, modifiedArguments: {...} }The call runs with the edits merged over the model's argumentsRefused, and the gate stays pending
Deny{ approved: false }The call doesn't runThe result is withheld

resume checks edits against the tool's closed parameter schema, and over HTTP a refused edit is a 422. An after-pause deny can't undo side effects, so name a call in interruptBefore if it must not happen at all. A tool named in both lists pauses twice.

A large result reaches the reviewer as a preview with requiresAcknowledgement: true. Approve with acknowledgeIncompleteResult: true to hand the full result on.

Fail closed

A throwing interruptOn predicate gates the call. A gated call that can't be put to a person is refused without running.

Who can approve

runtime.interrupts.resolve takes the session the caller was verified to own. An interrupt pending on any other session answers handled: false, exactly like an unknown id. A turn started with an actorId binds every gate it raises to that actor:

for await (const event of runtime.executeMessage(sessionId, prompt, { actorId: userId })) {
  // ...
}

// Later, from the request that carries the decision:
runtime.interrupts.resolve(interruptId, decision, sessionId, { actorId: userId });

createPleachRoute passes the non-empty resolveUserId value as the turn's actor, so only the user who sent the message can answer its approvals. Another user's resolve over HTTP answers 404 "Interrupt not pending".

Timeouts and releases

An unanswered gate is released after 3 minutes by default, and a host setting sets the window. The release is recorded as a policy decision, approval_window_expired. On the stream it arrives as interrupt.resolved with decision.approved: false and decision.decidedBy: "timeout-policy". The model is told a policy released the approval, never that the user declined.

A policy can also release a gate before the window ends, with code client_detached, bridge_capacity_evicted or owner_unresolved. Both kinds write the same durable interrupt.timeout row with decided_by: "policy". hitlUnansweredOutcome(policyCode) returns "released" for those three codes and "timeout" otherwise.

The full surface is on the Interrupts page, the event shapes are in Stream events, and multi-instance resolving is on API routes. Package status is on Packages.

Key takeaways

  • Approve before execution for any call with side effects; a review after it runs can only withhold the result.
  • Persistence is the real design choice: a checkpointer (LangGraph), a serialized run state (OpenAI Agents SDK), or your own messages array (AI SDK).
  • Bind the decision to the authenticated caller in the handler that submits it.
  • Set an answer window as policy, since a paused run waits until something resumes it.
  • Record "declined" and "never answered" as different outcomes, the way MCP elicitation separates decline from cancel.

References

  1. OWASP GenAI Security Project, "LLM06:2025 Excessive Agency." https://genai.owasp.org/llmrisk/llm062025-excessive-agency/
  2. Model Context Protocol, Specification 2025-06-18, "Tools." https://modelcontextprotocol.io/specification/2025-06-18/server/tools
  3. Model Context Protocol, Specification 2025-06-18, "Elicitation." https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation
  4. LangChain, "Interrupts" (LangGraph). https://docs.langchain.com/oss/python/langgraph/interrupts
  5. LangChain, "Human-in-the-loop" (middleware). https://docs.langchain.com/oss/python/langchain/human-in-the-loop
  6. OpenAI, "Human-in-the-loop," OpenAI Agents SDK for JavaScript. https://openai.github.io/openai-agents-js/guides/human-in-the-loop/
  7. Vercel, "Tool Calling," AI SDK Core. https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling

Frequently asked

How do you add human-in-the-loop approval to an AI agent tool call?

Pause the call before it executes, show the tool name and arguments to a person, and run it only on an explicit approve. LangGraph does this with interrupt() and Command(resume=...). The OpenAI Agents SDK uses needsApproval and result.interruptions. The AI SDK uses toolApproval and a tool-approval-response message. MCP leaves the prompt to the host application.

Should approval happen before or after the tool runs?

Before, whenever the call has side effects. A review after execution can withhold the result from the model, but it can't undo what the call already did. A post-execution review fits calls whose risk is in the output, such as a query that may return data the model shouldn't read.

Can a human edit the tool arguments before approving?

Yes, where the framework offers an edit decision. LangChain's human-in-the-loop middleware lists approve, edit, reject and respond, and edit modifies the tool arguments before execution. LangGraph lets you review and edit a tool call inside an interrupt. For user-supplied input, the AI SDK suggests a tool without an execute function whose result the client provides.

What happens if nobody answers an approval request?

The run stays paused until something resumes it. LangGraph's docs say the graph waits until you resume execution with a response. The OpenAI Agents SDK lets you serialize the run state and resume later without a running server. How long to wait, and how to record an expiry, is a policy your application sets.

What does OWASP say about agents calling tools without approval?

OWASP lists it as LLM06:2025 Excessive Agency. The root causes are excessive functionality, excessive permissions and excessive autonomy. Its mitigation "Require user approval" says to use human-in-the-loop control to require a human to approve high-impact actions before they are taken.

How does Pleach handle tool call approval?

Pleach gates tool calls with interruptBefore, which pauses a named call before it runs, and interruptAfter, which holds its result for review. Both fail closed. A turn started with an actorId only accepts a decision from that actor. An unanswered gate is released after 3 minutes by default and recorded as a policy decision, not as the user's refusal.

human-in-the-looptool call approvalAI agent interruptsexcessive agencyMCPLangGraph

More posts