Skip to content
A stream of lime particles pausing at a thin glowing gate on a dark background.
AI Agents

Agents That Know When to Stop and Ask

By Faraz ShahOct 8, 20264 min read

Clerify helps immigration law firms take a case from client documents to a filed USCIS petition. An AI agent can do much of that work, but it must never file anything without an attorney approving it first. I don't treat that as a limitation to work around. Attorneys are responsible for what gets filed, so the approval step is part of the product.

So the agent has to do something ordinary request-response code is bad at: stop halfway through a task, wait for hours or days, then carry on exactly where it left off.

Why a confirmation prompt isn't enough

The simple version is to have the model ask "should I go ahead?" in chat. That leaves approval as something the model chooses to do. A check that lives in the prompt can be skipped by a confused model or a clever input. Approval has to be enforced by the program, at a point in the graph the model can't route around.

Interrupt and resume

LangGraph has this built in. A node calls interrupt(), the graph saves its state and stops, and whatever you pass in later becomes the return value of that call. Here's a minimal sketch of the pattern:

python
from langgraph.types import Command, interrupt def review(state): decision = interrupt({ "action": "file_petition", "summary": state["summary"], }) return {"approved": decision == "approve"} graph = builder.compile(checkpointer=checkpointer) config = {"configurable": {"thread_id": case_id}} graph.invoke(inputs, config) # runs until review, then stops # Hours later, from any worker graph.invoke(Command(resume="approve"), config)

A conditional edge after this node then decides whether the run moves on to filing or ends. The important property is that the path to the filing step goes through review. There's no way to reach it otherwise.

One thing that catches people out: when the graph resumes, the interrupted node runs again from the top. Anything before the interrupt() call runs twice. Keep side effects out of that node, or put them after the interrupt, or give them their own node.

The checkpointer is what makes this production-ready

An in-memory checkpointer is fine for a demo and useless for this. The attorney might approve tomorrow, and by then that process is long gone. In Clerify, a database checkpointer holds every thread, so any worker can serve any turn. No request has to stay open and no worker has to remember anything.

If approval can take a day, the agent's state has to outlive every process that touched it.

Decide what gets checkpointed

Threads that last for days raise a question short-lived agents never face. What happens when you fix a bug in the system prompt while thousands of threads are mid-flight? If the prompt was saved in the checkpoint, those threads keep the old one.

So Clerify applies the system prompt per call and never checkpoints it. A prompt fix reaches threads that already exist, with no migration.

A related decision showed up on TradeDojo, which keeps two layers of state. The checkpointer holds what the model sees, and app tables hold what the UI renders and queries. It's tempting to make one store do both, but they change for different reasons and get read in different ways.

Show the reviewer something they can check

A pause is only useful if the person can make a real decision. "Approve this action?" just trains people to click yes. The interrupt payload should carry what a reviewer needs: what will happen, what it's based on, and what's still unresolved.

Clerify's form filler helps here by design. Every value in the fact ledger is typed and sourced, and every blank comes back as a typed open item, so an attorney sees exactly what's missing instead of hunting for it. On the chat side, each tool call renders as a widget for its kind, with confirmation verbs before anything changes. Coaches using Revel can similarly see what its assistant looked up, because every tool call is persisted.

Where to put the gates

Not everything needs approval, and too many prompts teach people to stop reading them. I sort actions by two questions: can this be undone, and does it leave the system?

Reading data and drafting need no gate. Changes that are easy to reverse can use a light confirmation. Anything irreversible or external, like filing with a government agency, sending a message or moving money, gets a hard interrupt that no prompt can bypass.

The takeaway

Human review is often treated as a sign the AI isn't good enough yet. I see it as the feature that lets you automate serious work at all. Build the pause into the graph, store state somewhere durable, keep prompts out of your checkpoints, and give reviewers real evidence. Then the agent can do the long, tedious middle of the job, and a person stays responsible for the step that matters.

Keep reading

Related posts.

A glowing lime central node connected by thin lines to smaller nodes on a dark background.
AI Agents

6 min read

Your Agent Is Only as Safe as Its Tools

Model output is untrusted input. Lessons from building agent tool layers for legal and trading products: validation, scoping, step limits and citations you can trust.

Read post
Rows of glowing lime dots on a dark background, with one dot left unlit below a threshold line.
RAG

6 min read

Your RAG Demo Needs a Failing Test

A new chunk size or prompt can quietly make answers worse, and nothing turns red. Here's how to make answer quality a merge check, with the harness from my open-source agent.

Read post