Human-in-the-loop
The agent pauses before a risky action and waits for a person to approve it.
Last updated
Analogy
A required PR review before merge. The bot can propose; a human presses the button.
In an agent
Use it for write actions: refunds, deletes, emails to customers.
Practice
Flashcards
- What is human-in-the-loop?The agent pauses for a person to approve an action before it runs.
- Interview: four guardrails against harmful actions?Step limits, Zod validation of arguments, least-privilege tools with approval for writes, and treating tool output as untrusted.
Interview questions
- How do you stop an agent doing something harmful?
- A maximum step limit.
- Zod validation of every tool argument.
- Least-privilege tools and human approval for write actions.
- Treat all tool output as untrusted data to defend against prompt injection.
Questions people ask
What is human-in-the-loop for AI agents?
The agent pauses before a risky action and waits for a person to approve it. The agent can propose a refund, a delete or an email to a customer, but a human presses the button. It is the agent version of a required code review before merging.
How do I add an approval step to an agent?
Mark write tools as needing approval. When the model calls one, save the agent's state, show the proposed action to a person, and stop. When they approve, resume from the saved state and run the tool. LangGraph's interrupt function and a checkpointer handle this pause and resume for you.