You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds the foundational components for human-in-the-loop
functionality in the Python OpenAI Agents SDK, matching the TypeScript
implementation.
**Completed Components:**
1. **Tool Approval Field** (tool.py)
- Added `needs_approval` field to FunctionTool
- Supports boolean or callable (dynamic approval)
- Updated function_tool() decorator
2. **ToolApprovalItem Class** (items.py)
- New item type for tool calls requiring approval
- Added to RunItem union type
3. **Approval Tracking** (run_context.py)
- Created ApprovalRecord class
- Added approval infrastructure to RunContextWrapper
- Methods: is_tool_approved(), approve_tool(), reject_tool()
- Supports individual and permanent approvals/rejections
4. **RunState Class** (run_state.py) - NEW FILE
- Complete serialization/deserialization support
- approve() and reject() methods
- get_interruptions() method
- Agent map building for name resolution
- 567 lines of serialization logic
5. **Interruptions Support** (result.py)
- Added interruptions field to RunResultBase
- Will contain ToolApprovalItem instances when paused
6. **NextStepInterruption** (run_state.py)
- New step type for representing interruptions
**Remaining Work:**
1. Add NextStepInterruption to NextStep union in _run_impl.py
2. Implement tool approval checking in run execution
3. Update run methods to accept RunState
4. Add comprehensive tests
5. Update documentation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments