Skip to main content
AutoGen is a framework from Microsoft for building AI agents and applications. It simplifies the creation of complex multi-agent systems, offering components for conversational AI (AgentChat), core multi-agent functionalities (Core), and integrations with external services (Extensions). AutoGen also provides a Studio for no-code agent prototyping. For more details, visit the official AutoGen documentation.
This guide assumes you have a basic understanding of AutoGen.
Weave integrates with AutoGen to help you trace and visualize the execution of your multi-agent applications. By simply initializing Weave, you can automatically track interactions within autogen_agentchat, autogen_core, and autogen_ext. This guide will walk you through various examples of how to use Weave with AutoGen.

Prerequisites

Before you begin, ensure you have AutoGen and Weave installed. You’ll also need any SDKs for the LLM providers you intend to use (e.g., OpenAI, Anthropic).
Set up your API keys as environment variables:

Basic Setup

Initialize Weave at the beginning of your script to start capturing traces.

Tracing a Simple Model Client

Weave can trace calls made directly to model clients within AutoGen.

Tracing a client create call

This example demonstrates tracing a single call to an OpenAIChatCompletionClient.
autogen-simple-client.png

Tracing a client create call with streaming

Weave also supports tracing streamed responses.
autogen-streaming-client.png

Weave records cached calls

AutoGen’s ChatCompletionCache can be used, and Weave will trace these interactions, showing whether a response came from the cache or a new call.
autogen-cached-client.png

Tracing an Agent with Tool Calls

Weave traces agents and their tool usage, providing visibility into how agents select and execute tools.
autogen-agent-tools.png

Tracing a GroupChat - RoundRobin

Interactions within group chats, such as RoundRobinGroupChat, are traced by Weave, allowing you to follow the conversation flow between agents.
round_robin_group_chat.png

Tracing Memory

AutoGen’s memory components can be traced with Weave. You can use @weave.op() to group memory operations under a single trace for better readability.
autogen-memory.png

Tracing RAG Workflows

Retrieval Augmented Generation (RAG) workflows, including document indexing and retrieval with memory systems like ChromaDBVectorMemory, are traceable. Decorating the RAG process with @weave.op() helps in visualizing the entire flow.
The RAG example requires chromadb. Install it with pip install chromadb.
autogen-rag.png

Tracing Agent Runtimes

Weave can trace operations within AutoGen’s agent runtimes, like SingleThreadedAgentRuntime. Using @weave.op() around the runtime execution function can group related traces.
autogen-runtime.png

Tracing Workflows (Sequential)

Complex agent workflows, defining sequences of agent interactions, can be traced. @weave.op() can be used to provide a high-level trace for the entire workflow.
autogen-sequential-workflow.png

Tracing Code Executor

Docker Required This example involves code execution using Docker and may not work in all environments (e.g., Colab directly). Ensure Docker is running locally if you try this.
Weave traces the generation and execution of code by AutoGen agents.
autogen-codegen.png

Learn More

This guide provides a starting point for integrating Weave with AutoGen. Explore the Weave UI to see detailed traces of your agent interactions, model calls, and tool usage.