How to Pause an AI Agent for Human Input
Pause an AI agent for human input with one step that sends the proposed action to an approval inbox and blocks until a person approves, edits or rejects it.
The problem: agents don't stop on their own
A tool-calling agent that runs in a loop — plan, call a tool, observe, repeat — has no natural place to stop and ask "should I actually do this?" Once a tool call is dispatched, the side effect happens. Bolting a confirm=True flag onto the tool doesn't help either: nothing forces the agent to check it before firing, and there's no record of who said yes.
What you actually need is a step in the graph that cannot proceed until an external decision arrives. That means the pause has to live outside the agent's own reasoning — in a place the agent can't talk itself past.
Where to insert the pause
If you're building on a graph-based framework (LangGraph, or a hand-rolled state machine), the natural spot is a dedicated node between "agent decided on an action" and "tool executes." That node does three things: push the proposed action somewhere durable, block on the decision, and only then hand control to the real tool.
import time
import requests
IMPRI_BASE = "https://api.impri.dev"
HEADERS = {"Authorization": f"Bearer {IMPRI_API_KEY}"}
def human_gate_node(state):
"""LangGraph node: pause the run until a human approves the pending action."""
proposed = state["pending_action"] # built by the previous agent node
resp = requests.post(f"{IMPRI_BASE}/v1/actions", headers=HEADERS, json={
"kind": "db.schema_change",
"title": f"Apply migration: {proposed['name']}",
"preview": {"format": "markdown", "body": proposed["sql"]},
"expires_in": 1800, # 30 minutes — this decision goes stale fast
"editable": ["preview.body"],
})
action_id = resp.json()["id"]
# Block the graph here. This is the pause.
while True:
result = requests.get(f"{IMPRI_BASE}/v1/actions/{action_id}", headers=HEADERS).json()
if result["status"] != "pending":
break
time.sleep(5)
if result["status"] != "approved":
state["migration_applied"] = False
return state
# Human may have edited the SQL before approving — always use final_preview
state["approved_sql"] = result["decision"]["final_preview"]["body"]
return stateThe graph node blocks on time.sleep(5) inside the loop, so the agent's own control flow physically cannot reach the next node — running the migration — without that status: "approved" coming back from the API.
What the human sees while the agent waits
The moment POST /v1/actions returns, a card appears in the reviewer's inbox (and a notification fires via email, ntfy, or a Slack/Discord/Telegram channel, if configured). The reviewer sees the title, the rendered preview, and — because editable includes preview.body — a text box to tweak the SQL before approving. Nothing about this requires the agent to be reachable; the agent is asleep in its polling loop, and the decision gets written to the action record whenever the human gets to it.
Handling a stale pause
expires_in matters more here than in a fire-and-forget action. A schema migration proposed 25 minutes ago against a database that's since changed shouldn't auto-apply just because a human finally taps approve. Set expires_in tight for anything time-sensitive (this example uses 1800 seconds), and treat expired the same as rejected in your node — fall through without executing, and let the agent decide whether to re-propose.
| Outcome | What the graph should do |
|---|---|
approved |
Proceed to the execution node with final_preview |
rejected |
Skip execution, log the reason if the reviewer left one |
expired |
Skip execution, treat as stale — re-plan if still relevant |
Pausing without a graph framework
If your agent is a plain loop rather than a graph, the same pattern applies — the "pause" is just the function call that doesn't return until the action is decided. For agents running inside Claude Code or another MCP client, `mcp.md` wraps this exact poll loop into a single blocking tool call (impri_await_decision), so you don't hand-write the while loop at all.
Frameworks with their own pause fit the same shape. The OpenAI Agents SDK stops a run before any tool marked needs_approval and can save it as a RunState, so the wait can outlast the process: see human-in-the-loop for the OpenAI Agents SDK for a version that turns each pause into an Impri card and resumes the run after the decision. Temporal does it with a signal: Temporal human-in-the-loop with an approval inbox wakes the workflow from Impri's webhook. Pydantic AI ends the run with DeferredToolRequests when the model calls a tool marked requires_approval: human-in-the-loop for Pydantic AI saves the message history and resumes it with the reviewer's decision. LlamaIndex pauses inside the tool itself with ctx.wait_for_event: human-in-the-loop for LlamaIndex agents saves the run when the card opens and resumes it in a second process after the decision.
When the input is information, not a decision
Everything above assumes the human answers a question about something the agent already drafted. Sometimes the agent is blocked on something it cannot draft at all: a client's logo, a login, a signed contract, facts only that person knows. An approval card is the wrong shape for that. The person is often outside your team, has no inbox in your tools, may take days, and needs typed fields and file uploads rather than an Approve button.
The pause itself stays the same (stop, wait for an external event, resume), but the request goes to a collection tool instead of an approval queue. BriefGate, built by the same developer as Impri, does this: the agent lists the items it needs, the person gets a portal link that works without an account, BriefGate sends the reminders, and the agent resumes once the items are in.
POST https://api.briefgate.dev/v1/intakes
Authorization: Bearer bg_live_...
Content-Type: application/json
{
"project_name": "Website relaunch",
"client": { "email": "[email protected]", "name": "Dana" },
"items": [
{ "key": "logo", "type": "image", "label": "Logo (SVG or PNG)" },
{ "key": "cms_login", "type": "secret", "label": "CMS admin login" }
]
}The agent then checks GET /v1/intakes/:id/status (or the get_intake_status MCP tool) and reads the values with GET /v1/intakes/:id/results when they arrive. Plenty of agents need both: collect the inputs with BriefGate, then send the finished draft through Impri for approval before anything goes live.
Next step
Start with quickstart to get an API key, then see the full REST/MCP walkthrough for the three-call pattern this pause node is built on. If you're integrating with Python specifically, sdk-python covers the client library.