Skip to main content
Tools

Human in the Loop

Make a tool wait for a person's approval before it acts.

A tool can refuse to act until a person approves. The check is in the tool, so the model can’t skip it: deploy only runs after someone approves that exact deploy.

Agentdeploy toolapproval Actorapproved: true or falseApproval UIconsume()waitingpromptapprove()
  • Each approval is an approval Actor keyed by the session and the version. consume returns whether it was approved and resets it, so one approval allows one deploy.
  • Without an approval, the tool returns terminate: true, which ends the turn instead of letting the model try again. The agent can sleep while it waits.
  • ApprovalDialog shows the request from the tool_execution_end event. Approve calls approve, then prompts the agent, which calls deploy again. streamingBehavior: "followUp" queues the answer if the agent is still running.
  • Protect the approval Actor with authentication so only approvers can call approve.

See React SDK for the rest of a chat UI.