Human in the Loop
TUTORIALInsert human approval steps into your agent workflows for sensitive operations.
The Safety Problem#
You don't want an agent to delete a production database or send an email to the CEO without checking first. AKIOS allows tools to pause execution and wait for permission.
State Running
Agent processes inputs and selects tools normally.
State Paused
Execution halts before sensitive tool call.
State Resumed
Continues with human approval or feedback.
1
FLAG_TOOL_AS_REQUIRES_APPROVAL
tools/email.ts
2
HANDLE_THE_INTERRUPTION
When the agent tries to call this tool, `run()` will return early with a status of `paused`.
server.ts
Persistent State
For this to work in a web app, you need a persistent `MemoryStore` so the agent can be rehydrated when the user approves (which might be hours later).