User Control Flow
UserControlFlowTools enable agents to pause execution and request input from users during conversations.
Prerequisites
Set up a virtual environment with the SDK setup guide, then install:
uv pip install agno openaiExample
The following agent can request user input during conversations:
from agno.agent import Agent
from agno.tools.user_control_flow import UserControlFlowTools
agent = Agent(
instructions=[
"You are an interactive assistant that can ask users for input when needed",
"Use user input requests to gather specific information or clarify requirements",
"Always explain why you need the user input and how it will be used",
"Provide clear prompts and instructions for user responses",
],
tools=[UserControlFlowTools()],
)
run_response = agent.run("Help me create a personalized workout plan")
while run_response.is_paused:
for requirement in run_response.active_requirements:
if requirement.needs_user_input:
for field in requirement.user_input_schema:
if field.value is None:
field.value = input(f"Enter {field.name}: ")
run_response = agent.continue_run(
run_response=run_response,
)
print(run_response.content)The run pauses each time the agent calls get_user_input. Fill the requested fields and call continue_run(run_response=run_response) to resume in memory. To resume by run_id instead, configure a database so the agent can retrieve the paused run. See Dynamic User Input for the full pattern.
Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
instructions | Optional[str] | None | Custom instructions for user interaction behavior. |
add_instructions | bool | True | Whether to add instructions to the agent. |
enable_get_user_input | bool | True | Enable user input request functionality. |
all | bool | False | Enable all functions. |
Toolkit Functions
| Function | Description |
|---|---|
get_user_input | Pause agent execution and request input from the user. |