UserFeedbackTools exposes a single ask_user tool. The agent presents structured questions with predefined options (single or multi-select), the run pauses, and execution resumes once the user provides their selections. This is a human-in-the-loop pattern for clarifying intent mid-run.
Prerequisites
The following example requires theopenai and sqlalchemy libraries.
Example
cookbook/02_agents/10_human_in_the_loop/user_feedback.py
Resolving the Pause
When the agent callsask_user, the run pauses with a user_feedback_schema. Collect the user’s selections and continue the run:
Question Schema
ask_user accepts a list of AskUserQuestion objects:
Each
AskUserOption has a label (1-5 words) and an optional description.