Notebooks
A
Arize AI
Autogen Agents Parallelization

Autogen Agents Parallelization

agentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringaiengineeringprompt-engineeringdatasetsllm-evalai-observabilityllm-evaluationsmolagentsanthropiclangchainautogen

Open In Colab

AutoGen Agents: Parallelization

In this tutorial, we'll explore parallel task execution with AutoGen and how to trace the workflow using Phoenix.

Parallelization is a powerful agent pattern where multiple tasks are run concurrently, significantly speeding up the overall process. Unlike purely sequential workflows, this approach is suitable when tasks are independent and can be processed simultaneously. Tracing allows us to monitor this concurrent flow and understand the timing of parallel branches.

AutoGen doesn't have a built-in parallel execution manager, but its core agent capabilities integrate seamlessly with standard Python concurrency libraries. We can use these libraries to launch multiple agent interactions concurrently.

By the end of this tutorial, you’ll learn how to:

  • Set up a basic AutoGen agent to perform specific tasks.

  • Execute a series of agent tasks in parallel using Python's threading library.

  • Use Phoenix to trace parallel agent interactions.

  • Compare parallelized and sequential agent workflows.

⚠️ You'll need an OpenAI Key for this tutorial.

Set up Keys and Dependencies

[ ]
[ ]
[ ]

Configure Tracing

[ ]

Example Parallelization Task: Product Description Generator

Define Agent With Parallelization

This section defines a parallelized workflow where multiple tasks are handled by a specialized AssistantAgent. Each task runs in its own thread, and tracing captures task-specific spans, including timing. A temporary UserProxyAgent is created for each thread to manage isolated chats with the agent.

As each task completes, the generated content and task metadata are collected into a shared results list using a lock. This setup enables concurrent LLM interactions.

In this example, we'll generate different components of a product description for a smartwatch (features, value proposition, target customer, tagline) by calling a marketing agent.

Diagram

The llm_config specifies the configuration used for all the assistant agents.

[ ]
[ ]
[ ]

Run and Trace Agent

Next, we run our agent. After all threads complete, the results are collected, sorted based on the original task order, and printed out.

[ ]

Define Agent Without Parallelization (Latency Comparison)

This section runs the same set of content generation tasks, but sequentially instead of in parallel. Each task is executed one after the other. This allows for a direct comparison of total execution time between sequential and parallel workflows.

[ ]

Run and Trace Sequential Agent

[ ]

View Results in Phoenix

The tracing results below focus on the performance of the parallelized workflow. Compared to the parallelized agent, the sequential version takes 3–4 times longer to complete. In Phoenix, we can view a detailed breakdown of LLM inputs and outputs, along with metadata such as latency, token counts, and model configurations.

Results