DEV Community

Zaima Sohail
Zaima Sohail

Posted on Originally published at Medium on

Human-in-the-Loop Isn’t a Weakness, It’s the Feature

I don’t think adding a human to an AI system means the model has failed. To me, it’s part of good design. Put a person in the right spot and the system gets safer to ship and a lot easier to trust.

When we imagine a great AI agent, we usually picture one that does everything on its own. Demos feed that picture. You type one prompt, nothing stops to ask you anything, and out comes a finished result. It looks great.

Real use is less forgiving. If an agent can send an email, issue a refund or delete a record, it can also get each of those wrong, and do it very quickly. So instead of asking “How do we remove the human?”, I’d ask “Where would a human’s judgment actually change the outcome?”

Where full autonomy goes wrong

Small errors add up. Say every step of an agent works 95% of the time, and the steps don’t affect each other. A 10-step task then goes through cleanly only about 60% of the time. Stretch it to 20 steps and you’re down to about 36%. Real steps aren’t this neatly independent, but you get the idea. The longer the chain, the more it needs checkpoints.

Not all mistakes cost the same. A clumsy draft takes a minute to fix. A wrong payment, a deleted table or a harmful health suggestion might not be fixable at all. A single accuracy score won’t show you that difference.

People know things the model doesn’t. A support agent might know that a customer was promised an exception on a call. A developer might know that the “unused” column quietly feeds a monthly report.

Someone has to own the decision. A model can recommend something, but it can’t take responsibility for it, apologise for it or be held to a policy. A person who has the authority to say no can.

Put the human where it matters

Reviewing everything is just as bad a design as reviewing nothing. What works better is to stop only at the actions where a person can prevent real harm, and let everything else flow.


human review loop · 1 decision, 3 outcomes

I’d write the hard rules directly in code. A model’s confidence can be one signal, but it shouldn’t be the only thing that decides whether the model needs supervision. And when a reviewer rejects something and says why, don’t waste it. Add that case to your test set.

A refund agent that knows when to ask

Here’s a small example. LangGraph’s interrupt() pauses a graph, saves its state and waits for an answer. Refunds up to $20 go through automatically, and anything bigger waits for a person. The code runs on LangGraph 1.2.24.

from typing import TypedDict

from langgraph.checkpoint.memory import InMemorySaver

from langgraph.graph import END, START, StateGraph

from langgraph.types import Command, interrupt

class Refund(TypedDict):

amount: float

status: str

def review(state: Refund):

if state[“amount”] <= 20: # hard rule: small refunds skip review

return {“status”: “approved”}

decision = interrupt({“question”: “Approve refund?”, “amount”: state[“amount”]})

if decision[“action”] == “reject”:

return {“status”: “rejected”}

return {“status”: “approved”, “amount”: decision.get(“amount”, state[“amount”])}

def execute(state: Refund):

if state[“status”] == “approved”:

print(f”Refunding ${state[‘amount’]:.2f}”) # call your payment API here

return {}

builder = StateGraph(Refund)

builder.add_node(“review”, review)

builder.add_node(“execute”, execute)

builder.add_edge(START, “review”)

builder.add_edge(“review”, “execute”)

builder.add_edge(“execute”, END)

graph = builder.compile(checkpointer=InMemorySaver())

config = {“configurable”: {“thread_id”: “refund-42”}}

paused = graph.invoke({“amount”: 250.0, “status”: “pending”}, config)

print(paused[“__interrupt__”][0].value) # show this to the reviewer

# Later: the reviewer approves a smaller amount

graph.invoke(Command(resume={“action”: “approve”, “amount”: 200.0}), config)

There are three things you shouldn’t miss:

• Save the state properly. InMemorySaver is fine for a demo. In production, use a database-backed checkpointer so a pending approval survives a restart.

• The thread ID is your bookmark. Resume with the same thread_id, otherwise the graph can’t find the paused run.

• The node starts over on resume. Any code before interrupt() runs again. So keep side effects like the payment after the approval, and make them safe to retry.

A human in the loop can still fail

Just adding an “Approve” button doesn’t give you oversight. This is where it usually goes wrong:

• Rubber-stamping. We tend to trust automated output more than we should. This is called automation bias. Show the reviewer the evidence behind a suggestion, not only the suggestion.

• Review fatigue. If everything needs approval, nothing really gets read. Keep an eye on the queue, and loosen the gate where the stakes are low and reviewers almost never change anything.

• No real power. A reviewer needs the time, context and authority to edit, reject or stop an action.

• Stale approvals. Prices and policies can change during a long pause, so check them again before acting.

Regulators are paying attention too. Article 14 of the EU AI Act says high-risk systems must support effective human oversight. That covers being aware of automation bias and being able to override or stop the system. The page lists 2 December 2027 as the start date for Annex III high-risk systems, and 2 August 2028 for Annex I.

Of course, there’s a trade-off. Review slows things down and takes someone’s time. I’d spend that time where a mistake costs more than the wait, and then adjust the gate based on what reviewers actually change.

For me, an agent that knows when to ask isn’t any less capable. It’s one I can trust with more.

Sources

• LangGraph documentation: Interrupts

• EU AI Act, Article 14: Human oversight

Top comments (0)