Documentation Index
Fetch the complete documentation index at: https://spacesail.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
This example demonstrates how to use the requires_user_input parameter to collect input for all fields in a tool. It shows how to handle user input schema and collect values for each required field.
Code
user_input_required_all_fields.py
"""🤝 Human-in-the-Loop: Allowing users to provide input externally
This example shows how to use the `requires_user_input` parameter to allow users to provide input externally.
"""
from typing import List
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools import tool
from agno.tools.function import UserInputField
from agno.utils import pprint
@tool(requires_user_input=True)
def send_email(subject: str, body: str, to_address: str) -> str:
"""
Send an email.
Args:
subject (str): The subject of the email.
body (str): The body of the email.
to_address (str): The address to send the email to.
"""
return f"Sent email to {to_address} with subject {subject} and body {body}"
agent = Agent(
model=OpenAIChat(id="gpt-5-mini"),
tools=[send_email],
markdown=True,
)
run_response = agent.run("Send an email please")
if run_response.is_paused: # Or agent.run_response.is_paused
for tool in run_response.tools_requiring_user_input: # type: ignore
input_schema: List[UserInputField] = tool.user_input_schema # type: ignore
for field in input_schema:
# Get user input for each field in the schema
field_type = field.field_type
field_description = field.description
# Display field information to the user
print(f"\nField: {field.name}")
print(f"Description: {field_description}")
print(f"Type: {field_type}")
# Get user input
if field.value is None:
user_value = input(f"Please enter a value for {field.name}: ")
# Update the field value
field.value = user_value
run_response = agent.continue_run(run_response=run_response)
pprint.pprint_run_response(run_response)
# Or for simple debug flow
# agent.print_response("Send an email please")
Usage
Create a virtual environment
Open the Terminal and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Install libraries
pip install -U agno openai
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
Create a Python file
Create a Python file and add the above code.touch user_input_required_all_fields.py
Run Agent
python user_input_required_all_fields.py
Find All Cookbooks
Explore all the available cookbooks in the Agno repository. Click the link below to view the code on GitHub:Agno Cookbooks on GitHub