Back to catalog / Agent safety
Add human approval to a side-effecting agent tool
Pause an agent run before an external change so a person can inspect and approve the exact action.
Goal
Make tool calls that require human judgment wait before any side effect.
Steps
- List tools that write, send, or delete data and include them in the approval policy. [openai-human] [openai-tools]
- Set
@function_tool(needs_approval=True)on the function tool—or a per-argument boolean policy—so Runner pauses before execution. [openai-human] [openai-tools] - Inspect
result.interruptions, callstate=result.to_state(), and show the reviewer the tool name, arguments, and target. [openai-human] [openai-tools] - Call
state.approve(interruption)only for explicit approval; usestate.reject(...)for denial, thenawait Runner.run(agent, state). [openai-human] [openai-tools] - Use a mock tool to verify approval executes, rejection does not, and the reviewed action matches actual arguments. [openai-human] [openai-tools]
How to verify
In a test environment, approve and reject once; only the approved path should call the side-effecting function.
Troubleshooting
If approval does not pause execution, check the SDK approval mechanism and ensure the tool has not run before the pause point.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
SDK approval is not a sandbox and does not replace resource authorization inside the tool; do not approve high-impact actions from model arguments alone.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/human_in_the_loop.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Make Agent behavior safer and easier to verify