I am trying to build an agent with the UserControlFlow tool.
I took the example from the docs, but change the run to work with stream
class EmailTools(Toolkit):
def __init__(self, *args, **kwargs):
super().__init__(
name="EmailTools", tools=[self.send_email, self.get_emails], *args, **kwargs
)
def send_email(self, subject: str, body: str, to_address: str) -> str:
"""Send an email to the given address with the given subject and body.
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}'"
def get_emails(self, date_from: str, date_to: str) -> str:
"""Get all emails between the given dates.
Args:
date_from (str): The start date (in YYYY-MM-DD format).
date_to (str): The end date (in YYYY-MM-DD format).
"""
return [
{
"subject": "Meeting Reminder",
"body": "Don't forget about our meeting tomorrow",
"from_address": "boss@company.com",
"date": date_from,
},
{
"subject": "Project Update",
"body": "The project is progressing well",
"from_address": "team@company.com",
"date": date_to,
},
]
def handle_user_input_streaming(agent: Agent):
"""Handle user input collection during streaming"""
print("\n๐ Agent is requesting user input...")
for tool in agent.run_response.tools_requiring_user_input:
input_schema: List[UserInputField] = tool.user_input_schema
print(f"\n๐ Tool: {tool.tool_name}")
print("=" * 50)
for field in input_schema:
print(f"\n๐ Field: {field.name}")
print(f"๐ Description: {field.description}")
print(f"๐ง Type: {field.field_type.__name__}")
if field.value is None:
# Get user input
user_value = input(f"โก๏ธ Please enter a value for {field.name}: ")
field.value = user_value
print(f"โ
Set {field.name} = {user_value}")
else:
print(f"โน๏ธ Value already provided: {field.value}")
# Create agent with UserControlFlowTools for dynamic user input
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[EmailTools(), UserControlFlowTools()],
markdown=True,
debug_mode=True,
)
print("๐ Starting streaming agent with UserControlFlowTools...")
print("=" * 60)
# Start streaming execution
agent.print_response(
"I need to send an email about a project update. Please help me compose and send it.",
stream=True,
stream_intermediate_steps=True,
)
When running the script I am getting an error
agno.exceptions.ModelProviderError: An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_rjvLXvTJrHhE7hX2nmYmXd4F
Running with Agno 1.7.2
Thank you very much!