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
feat: integrate HITL approval checking into run execution loop
This commit integrates the human-in-the-loop infrastructure into the
actual run execution flow, making tool approval functional.
**Changes:**
1. **NextStepInterruption Type** (_run_impl.py:205-210)
- Added NextStepInterruption dataclass
- Includes interruptions list (ToolApprovalItems)
- Added to NextStep union type
2. **ProcessedResponse Enhancement** (_run_impl.py:167-192)
- Added interruptions field
- Added has_interruptions() method
3. **Tool Approval Checking** (_run_impl.py:773-848)
- Check needs_approval before tool execution
- Support dynamic approval functions
- If approval needed:
* Check approval status via context
* If None: Create ToolApprovalItem, return for interruption
* If False: Return rejection message
* If True: Continue with execution
4. **Interruption Handling** (_run_impl.py:311-333)
- After tool execution, check for ToolApprovalItems
- If found, create NextStepInterruption and return immediately
- Prevents execution of remaining tools when approval pending
**Flow:**
Tool Call → Check needs_approval → Check approval status →
If None: Create interruption, pause run →
User approves/rejects → Resume run →
If approved: Execute tool
If rejected: Return rejection message
**Remaining Work:**
- Update Runner.run() to accept RunState
- Handle interruptions in result creation
- Add tests
- Add documentation/examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments