Human-in-the-loop compared: LangGraph, OpenAI Agents SDK, MCP, Claude Code, Codex

How LangGraph, the OpenAI Agents SDK, MCP, Claude Code and Codex pause an agent for a person, what survives a restart, and when a separate approval service adds something.

· 11 min read

Every agent framework now has a way to stop and ask a person. They differ in what stops, where the question appears, and what is left when nobody answers. This compares five of them as their documentation describes them in November 2026, then looks at when a separate approval service is worth adding, and when it is not.

These tools change fast. Every claim below comes from the official page listed under Sources; check there for anything newer.

For each one, six questions:

  1. What makes it pause?
  2. Where does the person answer?
  3. What happens if nobody answers, or the process restarts?
  4. Is there a durable record of who approved what?
  5. Are there rules, such as amount limits?
  6. Does it work across several agents and vendors?

LangGraph: interrupt and a checkpointer

A node or a tool calls interrupt() with a JSON value. The graph stops at that line, the checkpointer saves its state, and the value comes back to whoever ran the graph. To go on, you run the graph again with Command(resume=...) and the same thread_id. The resume value becomes what interrupt() returns.

from langgraph.types import Command, interrupt

def approve_refund(state: State):
    approved = interrupt(
        {"question": "Refund this order?", "order": state["order_id"]}
    )
    return {"approved": approved}

graph = builder.compile(checkpointer=checkpointer)  # a durable one in production
config = {"configurable": {"thread_id": "order-1182"}}

result = graph.invoke({"order_id": "1182"}, config)
print(result["__interrupt__"])  # the question, for your own UI to show

# Later, in any process that reaches the same checkpointer:
graph.invoke(Command(resume=True), config)
  • Where the person answers: in your application. It reads the interrupt, shows it, and sends the answer back. LangSmith Agent Server offers the same over its API, and can ask an MCP client through elicitation.
  • Nobody answers: the graph waits indefinitely. A time limit is yours to build.
  • Restart: with a durable checkpointer, such as PostgresSaver, the pause survives and any process can resume it. InMemorySaver loses it. On resume the node runs again from its first line, so code before interrupt() must be safe to repeat.
  • Record: the checkpointer keeps the thread’s state, step by step. It is working state, not an audit log: it knows who answered only if your code writes that in, and the docs suggest pruning old checkpoints as they grow.
  • Rules: LangChain’s HumanInTheLoopMiddleware sets, per tool, which answers are allowed (approve, edit, reject, respond), and a when predicate can pause only some calls, such as SQL that is not a plain SELECT. Any limit is code in one agent.
  • Reach: graphs built with LangGraph, each with its own threads and its own way of showing questions.

OpenAI Agents SDK: needs_approval

A tool marked needs_approval in Python, or needsApproval in TypeScript, does not run when the model calls it. The value is true or a function of the call’s arguments. The run stops and returns the waiting calls as interruptions. You approve or reject each one on the run’s state and run it again. Handoffs and nested Agent.as_tool() runs surface on the same outer run, and MCP servers have their own require_approval setting.

from agents import Agent, Runner, RunState
from agents.decorators import tool

@tool(needs_approval=True)
async def cancel_order(order_id: int) -> str:
    return f"Cancelled order {order_id}"

agent = Agent(name="Support agent", tools=[cancel_order])

# Inside an async function:
result = await Runner.run(agent, "Cancel order 1182")
if result.interruptions:
    saved = result.to_state().to_string()  # keep it on your server
    # Later, perhaps in another process, once a person has decided:
    state = await RunState.from_string(agent, saved)
    for item in state.get_interruptions():
        state.approve(item)  # or state.reject(item)
    result = await Runner.run(agent, state)
  • Where the person answers: wherever your application shows the interruptions. For a browser or phone, the docs say to keep the state on your server, authenticate the reviewer, and never take the reviewer’s identity from the request.
  • Nobody answers, or a restart: a paused run is a value, RunState, that you serialize and restore later, in another process if need be. How long it may wait is up to you. The docs also warn that approval is not exactly-once: if the process stops after a tool acted but before the new state was saved, resuming can run it again, so give side effects an idempotency key.
  • Record: the run state holds the decisions it needs to continue. Who decided, and when, is whatever your application stores.
  • Rules: a needs_approval function is a policy in code, per tool, such as asking only when an email’s subject mentions a refund. always_approve keeps a yes for later calls to the same tool. Guardrails check input, output and tool calls automatically, without a person.
  • Reach: the agents in one run, including handoffs.

MCP: tool prompts and elicitation

Two different things in MCP get called approval. The first is the client’s prompt before a tool call. The specification says there should always be a human in the loop who can deny tool calls, and leaves the prompt to the client. Claude Code, Codex and VS Code each decide how it looks, what can be allowed for a session or for good, and what runs without asking.

The second is elicitation: a server asks the user for input in the middle of a request, through a form or a link. In the current revision, 2026-07-28, the server answers a tool call with input_required, the client asks the user, then repeats the call with the answer. A server can use it to ask “Refund €49 to ana@example.com?” and get back:

{
  "action": "accept",
  "content": { "approved": true }
}
accept
The user approved and sent the form.
decline
The user said no.
cancel
The user closed it without choosing.
  • Where the person answers: in the client they are using, which must show which server is asking and offer decline and cancel.
  • Nobody answers, or a restart: the specification leaves both to the client. A server needs no state for elicitation, so a question nobody answered goes away with the client, unless the server keeps its own.
  • Record and rules: none in the protocol. Tool annotations describe how a tool behaves, and clients must treat them as untrusted unless the server is trusted. Clients add their own rules: Codex asks before an app or MCP tool call marked destructive.
  • Reach: the widest here. One server works in many clients, but each keeps its own prompts and its own approvals.

Claude Code: permission modes, rules and hooks

Claude Code decides before each tool call whether to run it, ask, or refuse. A permission mode sets the baseline: default (shown as Manual), acceptEdits, plan, auto, dontAsk and bypassPermissions. In auto, a classifier model reviews actions instead of you; from version 2.1.283 it is the starting mode for interactive terminal and VS Code sessions. Rules in the settings allow, ask or deny by tool and pattern, checked deny first, then ask, then allow:

{
  "permissions": {
    "allow": ["Bash(npm run *)"],
    "ask": ["Bash(git push *)"],
    "deny": ["Read(./.env)"]
  }
}

A PreToolUse hook runs a command of yours before each matching tool call and answers allow, deny, ask or defer. Its allow never overrides a deny or ask rule. A PermissionRequest hook runs when Claude Code is about to show a prompt.

  • Where the person answers: the terminal, IDE or app running the session. With Remote Control, also the Claude app on a phone, which can get a push notification when a prompt waits. The computer has to stay on and the session running, and it needs a Claude plan rather than an API key.
  • Nobody answers: an interactive prompt stays open until someone answers. In a claude -p run, a call that needs approval is denied unless a rule, a hook or a permission callback approves it. There a hook can also defer a single call: the run ends with the call pending, and claude -p --resume picks it up later.
  • Record: with OpenTelemetry turned on, each accept or reject is a claude_code.tool_decision event that says whether the settings, a hook or the user decided, sent to your own collector.
  • Rules: tool and command patterns, and managed settings an organization can enforce on every machine. Nothing knows about amounts.
  • Reach: Claude Code, one session at a time.

Codex: sandbox, approval policy and rules

Codex has two layers. The sandbox (read-only, workspace-write or danger-full-access) decides what a command can reach. The approval policy decides when Codex stops to ask. With on-request, Codex works inside the sandbox and asks before leaving it, for example to use the network or write outside the workspace. never never asks, for CI. The old untrusted value is retired; marking a project untrusted brings back the stricter behaviour. Rules, still marked experimental, match command prefixes:

# ~/.codex/config.toml
sandbox_mode = "workspace-write"
approval_policy = "on-request"

# ~/.codex/rules/default.rules
prefix_rule(
    pattern = ["git", "push"],
    decision = "prompt",
    justification = "Pushes need a person",
)
  • Where the person answers: the CLI, IDE extension or ChatGPT desktop app, and for a connected computer, the ChatGPT mobile app. With approvals_reviewer = "auto_review", a reviewer agent decides the eligible requests instead of you.
  • Nobody answers: the prompt waits in the session. Auto-review fails closed: when it times out, the action does not run.
  • Record: opt-in OpenTelemetry logs codex.tool_decision, approved or denied, and whether the configuration or the user decided. It is off by default.
  • Rules: prefix_rule says allow, prompt or forbidden, and the most restrictive match wins. Admins can enforce rules through requirements.toml. Nothing knows about amounts.
  • Reach: Codex only. Its PreToolUse and PermissionRequest hooks let a command of yours decide, which is how an outside service plugs in.

At a glance

How each option pauses an agent for a person
OptionWhere a person answersNobody answers, or a restartWho approved, on recordRules and limitsOther agents and vendors
LangGraphWhere a person answersYour own UI, from __interrupt__Nobody answers, or a restartWaits indefinitely; survives a restart with a durable checkpointerWho approved, on recordOnly what your app writes into stateRules and limitsPer tool, and when on its arguments (middleware)Other agents and vendorsLangGraph graphs only
OpenAI Agents SDKWhere a person answersYour own UI, from interruptionsNobody answers, or a restartWaits; survives a restart if you store the RunStateWho approved, on recordOnly what your app storesRules and limitsneeds_approval as a function, per toolOther agents and vendorsAgents in the same run
MCPWhere a person answersThe client's prompt or formNobody answers, or a restartUp to the clientWho approved, on recordNone in the protocolRules and limitsNone; tool annotations are hintsOther agents and vendorsAny client, each with its own prompts
Claude CodeWhere a person answersTerminal, IDE or app; a phone with Remote ControlNobody answers, or a restartThe prompt stays open; denied in a non-interactive runWho approved, on recordOpenTelemetry events, if turned onRules and limitsAllow, ask and deny by tool and patternOther agents and vendorsClaude Code only
CodexWhere a person answersCLI, IDE or app; the ChatGPT mobile appNobody answers, or a restartThe prompt waits; auto-review fails closedWho approved, on recordOpenTelemetry events, if turned onRules and limitsAllow, prompt and forbidden by command prefixOther agents and vendorsCodex only
An approval service (VariantGate)Where a person answersAn inbox on any device; email, push, Slack, Teams or DiscordNobody answers, or a restartExpires at its time limit and means no; the agent's own run is not savedWho approved, on recordA sealed record of every decision and who made itRules and limitsAllow, ask and deny by action and key; amount limits, budgets, two peopleOther agents and vendorsAny agent that can make an HTTP or MCP call

When the built-in option is enough

Often. Use what your framework already has when:

  • One developer is at the terminal. Claude Code’s and Codex’s prompts, rules and sandboxes are made for that, and now reach a phone too. For shell commands their prefix rules are more precise than any rule that matches an action name.
  • One application, one framework, your own UI. An interrupt with a durable checkpointer, or a stored RunState, pauses for as long as it takes and resumes exactly where the run stopped. A separate service does not save your agent’s state.
  • The user in the chat is the one who decides. A tool prompt or an elicitation asks them where they already are. An inbox would add a step for nothing.
  • Nothing may leave your network. An outside service sees what your agents want to do. Built-in prompts keep that local.

When a separate approval service adds something

The coding agents ask whoever runs the session. The SDKs leave the reviewer, the screen and the record to you. A service such as VariantGate is that part, built once, outside all of them. An agent asks it with one HTTP call, an MCP tool call or a hook, and acts only when the answer says allowed: true. That adds:

  • One inbox for every agent and vendor. A LangGraph app, an OpenAI Agents SDK service, Claude Code on three laptops and an n8n flow ask in the same place. See the integrations.
  • A decider who is not at the keyboard. Approve in the inbox on a phone, from an email link, or from a Slack, Teams or Discord message, with a push notification when a request waits. A teammate can answer, and the decision is recorded in the name of whoever signed in, never taken from the agent’s request.
  • Rules that know about money. Always allow payment.refund up to €20 and €500 a day, ask above that. A request with no amount never passes a limit. See rules.
  • Two people for the big ones. An ask rule can need two or three different people to approve.
  • One record. Every decision, who made it and what came of it, sealed in a hash chain so a changed entry shows. See the record.
  • One stop switch. Any member can pause every agent, or one; only an owner can resume. See emergency stop.
  • No self-approval. An agent key can ask and read its own requests. It can never decide one.

The inbox, notifications, the record and the stop switch are on every plan. Rules, amount limits and budgets need Pro; inviting teammates and two-person approval need Team; routing to named people needs Business.

What a separate service does not do

  • It does not pause your program. Your code waits for the answer, holding a call open for up to 30 seconds at a time. The request expires at its time limit, 15 minutes unless the agent sets another between 10 seconds and 7 days, and expired means no.
  • It sees only what is sent to it. An agent that never asks is not stopped by a pause. Over MCP the model picks the action name itself; a check in the tool’s code or a hook does not depend on the model.
  • It is one more thing on the path. The SDKs fail closed: if the service cannot be reached, the action does not run. That is the safe default, and also a new way for work to stop.
  • Its rules match actions, not commands. A rule for shell.run covers every command. Keep the coding agents’ own prefix rules for that.

A sensible split

  1. Let the framework refuse what never needs asking: sandbox, deny rules, read-only tools.
  2. Let it hold the run: a checkpointer or a stored run state. Keep the approval request’s id in that state, so a restarted run checks the same request instead of asking again.
  3. Send the decisions that matter to a person who may not be at the terminal: a check in the tool, the MCP server, or a hook.

The pattern in code, for any framework, is in how to add human approval to an AI agent.

Sources

  1. LangGraph: Interrupts. interrupt(), Command(resume=...), thread_id, waiting indefinitely, re-running the node on resume.
  2. LangGraph: Persistence. Checkpointers, InMemorySaver lost on restart, PostgresSaver and SqliteSaver, pruning old checkpoints.
  3. LangChain: Human-in-the-loop middleware. interrupt_on, allowed decisions and the when predicate.
  4. LangSmith: Human-in-the-loop over MCP. Agent Server answers interrupts through MCP elicitation.
  5. OpenAI Agents SDK (Python): Human-in-the-loop. needs_approval, interruptions, RunState, server-side approvals, recovering after a crash.
  6. OpenAI Agents SDK (TypeScript): Human-in-the-loop. needsApproval and result.state.approve().
  7. OpenAI Agents SDK (Python) reference: RunState, to_string(), from_string() and get_interruptions().
  8. OpenAI: Guardrails and human review.
  9. Model Context Protocol 2026-07-28: Elicitation. Form and URL modes; accept, decline and cancel.
  10. Model Context Protocol 2026-07-28: Multi round-trip requests.
  11. Model Context Protocol 2026-07-28: Tools. A human in the loop who can deny tool calls; annotations are untrusted.
  12. Visual Studio Code: Manage approvals and permissions.
  13. Claude Code: Choose a permission mode. The six modes, auto as the starting mode, denials in -p runs.
  14. Claude Code: Configure permissions. Allow, ask and deny rules, their order, managed settings.
  15. Claude Code: Hooks reference. PreToolUse decisions, defer, PermissionRequest.
  16. Claude Code: Remote Control. Permission prompts and push notifications on a phone.
  17. Claude Code: Monitoring. The tool_decision event and its source.
  18. Codex: Agent approvals and security. Sandbox modes, approval policies, auto-review, telemetry.
  19. Codex: Rules. prefix_rule with allow, prompt and forbidden.
  20. Codex: Hooks. PreToolUse and PermissionRequest.
  21. Codex on mobile. Approving requested actions from a phone.