Agent.run() function runs the agent and generates a response, either as a RunResponse object or a stream of RunResponse objects.
Many of our examples use agent.print_response() which is a helper utility to print the response in the terminal. It uses agent.run() under the hood.
Running your Agent
Here’s how to run your agent. The response is captured in theresponse.
RunResponse
TheAgent.run() function returns a RunResponse object when not streaming. It has the following attributes:
Understanding MetricsFor a detailed explanation of how metrics are collected and used, please refer to the Metrics Documentation.
Streaming Responses
To enable streaming, setstream=True when calling run(). This will return an iterator of RunResponseEvent objects instead of a single response.
From
agno version 1.6.0, the Agent.run() function returns an iterator of RunResponseEvent, not of RunResponse objects.Streaming Intermediate Steps
For even more detailed streaming, you can enable intermediate steps by settingstream_intermediate_steps=True. This will provide real-time updates about the agent’s internal processes.
Handling Events
You can process events as they arrive by iterating over the response stream:Storing Events
You can store all the events that happened during a run on theRunResponse object.
RunResponseContentEvent event is not stored. You can modify which events are skipped by setting the events_to_skip parameter.
For example:
Event Types
The following events are yielded by theAgent.run() and Agent.arun() functions depending on the agent’s configuration:
Core Events
Control Flow Events
Tool Events
Reasoning Events
Memory Events
See detailed documentation in the RunResponseEvent documentation.
Structured Input
An agent can be provided with structured input (i.e a pydantic model) by passing it in theAgent.run() or Agent.print_response() as the message parameter.