Skip to main content
The Workflow.run() function runs the agent and generates a response, either as a WorkflowRunOutput object or a stream of WorkflowRunOutput objects. Many of our examples use workflow.print_response() which is a helper utility to print the response in the terminal. This uses workflow.run() under the hood.

Running your Workflow

Here’s how to run your workflow. The response is captured in the response.
The Workflow.run() function returns a WorkflowRunOutput object when not streaming. Here is detailed documentation for WorkflowRunOutput.

Async Execution

The Workflow.arun() function is the async version of Workflow.run(). Here is an example of how to use it:

Streaming Responses

To enable streaming, set stream=True when calling run(). This will return an iterator of WorkflowRunOutputEvent objects instead of a single response.

Streaming all events

By default, when you stream a response, only the WorkflowStartedEvent and WorkflowCompletedEvent events will be streamed (together with all the Agent and Team events). You can also stream all events by setting stream_events=True. This will provide real-time updates about the workflow’s internal processes:

Streaming Executor Events

The events from Agents and Teams used inside your workflow are automatically yielded during the streaming of a Workflow. You can choose not to stream these executor events by setting stream_executor_events=False. The following Workflow events will be streamed in all cases:
  • WorkflowStarted
  • WorkflowCompleted
  • StepStarted
  • StepCompleted
See the following example:

Async Streaming

The Workflow.arun(stream=True) returns an async iterator of WorkflowRunOutputEvent objects instead of a single response. So for example, if you want to stream the response, you can do the following:
See the Async Streaming example for more details.

Event Types

The following events are yielded by the Workflow.run() and Workflow.arun() functions depending on the workflow’s configuration:

Core Events

Event TypeDescription
WorkflowStartedIndicates the start of a workflow run
WorkflowCompletedSignals successful completion of the workflow run
WorkflowErrorIndicates an error occurred during the workflow run

Step Events

Event TypeDescription
StepStartedIndicates the start of a step
StepCompletedSignals successful completion of a step
StepErrorIndicates an error occurred during a step

Step Output Events (For custom functions)

Event TypeDescription
StepOutputIndicates the output of a step

Parallel Execution Events

Event TypeDescription
ParallelExecutionStartedIndicates the start of a parallel step
ParallelExecutionCompletedSignals successful completion of a parallel step

Condition Execution Events

Event TypeDescription
ConditionExecutionStartedIndicates the start of a condition
ConditionExecutionCompletedSignals successful completion of a condition

Loop Execution Events

Event TypeDescription
LoopExecutionStartedIndicates the start of a loop
LoopIterationStartedEventIndicates the start of a loop iteration
LoopIterationCompletedEventSignals successful completion of a loop iteration
LoopExecutionCompletedSignals successful completion of a loop

Router Execution Events

Event TypeDescription
RouterExecutionStartedIndicates the start of a router
RouterExecutionCompletedSignals successful completion of a router

Steps Execution Events

Event TypeDescription
StepsExecutionStartedIndicates the start of Steps being executed
StepsExecutionCompletedSignals successful completion of Steps execution
See detailed documentation in the WorkflowRunOutputEvent documentation.

Storing Events

Workflows can automatically store all execution events for analysis, debugging, and audit purposes. Filter specific event types to reduce noise and storage overhead while maintaining essential execution records. Access stored events via workflow.run_response.events and in the runs column of your workflow’s session database (SQLite, PostgreSQL, etc.).
  • store_events=True: Automatically stores all workflow events in the database
  • events_to_skip=[]: Filter out specific event types to reduce storage and noise
Access all stored events via workflow.run_response.events Available Events to Skip:
Use Cases
  • Debugging: Store all events to analyze workflow execution flow
  • Audit Trails: Keep records of all workflow activities for compliance
  • Performance Analysis: Analyze timing and execution patterns
  • Error Investigation: Review event sequences leading to failures
  • Noise Reduction: Skip verbose events like step_started to focus on results
Configuration Examples
See this example for more information.

Agno Telemetry

Agno logs which model an workflow used so we can prioritize updates to the most popular providers. You can disable this by setting AGNO_TELEMETRY=false in your environment or by setting telemetry=False on the workflow.
or:
See the Workflow class reference for more details.

Developer Resources