Module 4 · Reliability & safety

Human-in-the-loop and approval checkpoints

5 min read

Full autonomy is rarely desirable. Publishing content, messaging a customer, modifying production data, committing spend: these actions deserve a human look. Human-in-the-loop is not an admission of weakness; it's a design decision that puts human judgment exactly where it has the most value.

Where to put the human?

A human asked too often ends up approving everything without reading. Place approval points according to two criteria:

ReversibleIrreversible
Low impactAutonomyAutonomy + logging
High impactAutonomy + after-the-fact reviewPrior approval

In Atlas, publishing a note is the approval point: it's the step where an error becomes visible to the outside world.

interrupt: pausing a graph

LangGraph provides the interrupt() primitive. Called inside a node, it suspends execution, saves the state and returns a payload to the caller. The graph resumes later — a second or three days later — when the caller provides an answer.

Here is Atlas's approval node:

def human_review(state: dict) -> Command[Literal["writer", "__end__"]]:
    # The graph pauses here; it resumes with Command(resume={...})
    decision = interrupt({"draft": state["draft"], "review": state["review"]})
    if decision.get("approved"):
        return Command(goto=END, update={"approved": True})
    feedback = decision.get("feedback") or "Rework the note."
    return Command(
        goto="writer",
        update={"review": {"verdict": "revise", "issues": [feedback], "score": 0},
                "revisions": state.get("revisions", 0) + 1},
    )

The payload passed to interrupt is what the human will see: the note and the critic's review. Give the reviewer everything needed to decide quickly and well — without forcing them to look for context elsewhere.

The three prerequisites

1. A checkpointer

To resume later, the state must be saved. That's why build_graph always compiles with a checkpointer:

return builder.compile(checkpointer=checkpointer or InMemorySaver())

InMemorySaver is fine for tests; in production, use a persistent checkpointer (Postgres, for instance — lesson 6.3), otherwise a server restart wipes out every pending approval.

2. A thread identifier (thread_id)

Each execution is identified by a thread_id passed in the config. It's what lets you find the suspended execution again:

config = {"configurable": {"thread_id": uuid.uuid4().hex}, "recursion_limit": 50}

3. Resuming with Command(resume=...)

The loop in examples/04_run_atlas.py shows the full cycle:

result = graph.invoke({"question": question, "revisions": 0}, config)
while "__interrupt__" in result:
    pending = result["__interrupt__"][0].value          # the payload passed to interrupt()
    print(pending["draft"])
    answer = input("Publish? [y]es / otherwise, type your feedback: ").strip()
    decision = ({"approved": True} if answer.lower() in {"y", "yes"}
                else {"approved": False, "feedback": answer})
    result = graph.invoke(Command(resume=decision), config)   # same thread_id

The value passed to Command(resume=...) becomes the return value of interrupt() inside the node. In a web application, the interrupt is stored, the interface displays the note, and a click on "Publish" calls invoke(Command(resume=…)) with the same thread_id.

Pitfall #1: the node restarts from the beginning

On resume, LangGraph re-runs the node from the start, up to the interrupt() call, which then returns the provided value. All the code placed before interrupt() therefore runs twice.

def risky_review(state):
    send_notification(state["draft"])     # ⚠️ runs a second time on resume!
    decision = interrupt({"draft": state["draft"]})
    ...

Resulting rules:

  1. Put interrupt() at the start of the node, or isolate approval in a dedicated node (like human_review in Atlas).
  2. Make idempotent any side effect located before the interrupt (lesson 1.4).
  3. Don't wrap interrupt() in a generic try/except: pausing relies on an internal exception you would intercept.
  4. The payload must be JSON-serializable.

Beyond approval: editing the state

The human can do more than approve or reject. Atlas accepts text feedback that sends the note back to the writer. You can go further and let the human edit directly:

decision = interrupt({"draft": state["draft"], "review": state["review"]})
if decision.get("edited_draft"):
    return Command(goto=END, update={"draft": decision["edited_draft"], "approved": True})

The human then becomes an agent like any other — the most reliable, and the slowest. Also plan for expiry: an approval with no answer after 48 hours should trigger a reminder or a documented default decision (most often: don't publish).

Measuring approval quality

Two simple indicators reveal a dysfunctional human-in-the-loop:

  • An approval rate close to 100% with very short decision times: the human no longer reads. Reduce the number of approval points or present more concise information.
  • A high rejection rate: the upstream system isn't ready. Human feedback is then a gold mine for improving prompts and building an evaluation set (module 5).

Key takeaways

  • Put human approval on high-impact, irreversible actions — not everywhere.
  • interrupt(payload) suspends the graph; Command(resume=value) resumes it, on the same thread_id.
  • A checkpointer is required — persistent in production.
  • On resume, the node restarts from the beginning: interrupt() at the top of the node, idempotent side effects, no generic try/except around it.

Hands-on

  1. Run ATLAS_FAKE_LLM=1 python examples/04_run_atlas.py, reject the first note with feedback, then approve.
  2. Add the ability to edit the note directly (edited_draft) and a matching test.
  3. Write a test demonstrating that code placed before interrupt() runs twice.

Resources