AutoGen Integration
Context propagation and distributed tracing for Microsoft AutoGen multi-agent conversations. Trace context flows across agent message boundaries automatically.
AutoGen (Microsoft) is a framework for building multi-agent AI applications where agents communicate through structured message exchanges.

Getting Started
Install the SDK
Install @zespan/sdk alongside your AutoGen setup.
npm install @zespan/sdkInject and propagate trace context
Use injectAutoGenContext to attach trace context to outgoing messages and extractAutoGenContext to read it on the receiving side. This links all agent messages into a single unified trace.
import { Zespan, injectAutoGenContext, extractAutoGenContext, attachTraceToAutoGenMessage } from '@zespan/sdk';
const lt = new Zespan({ apiKey: process.env.ZESPAN_API_KEY });
// Sender: attach trace context to outgoing message
const outgoingMessage = attachTraceToAutoGenMessage(
{ role: 'user', content: userInput },
lt.currentContext()
);
// Receiver: extract trace context from incoming message
const ctx = extractAutoGenContext(incomingMessage);
// Use ctx to continue the trace on the receiving agentView traces in Zespan
Multi-agent AutoGen conversations appear as unified traces. Each agent's contribution is a separate span attributed to its agent_name.
What's captured automatically
- Distributed context propagation: trace context flows across agent message boundaries
- Unified traces: multi-agent conversations appear as a single trace, not N separate ones
- Per-agent attribution: cost and latency attributed to each AutoGen agent role
- Conversation thread: full message exchange captured as a session
- Tool calls: AutoGen function calls and code execution as child spans
- Error attribution: failures attributed to the correct agent in the conversation
FAQ
Does this work with AutoGen's GroupChat?
Yes. Attach trace context to GroupChat messages the same way. All agents in the group chat share the same trace context, so the full conversation appears as a single unified trace.
Do I need to modify every AutoGen agent?
You need to attach context on the sender side and extract it on the receiver side. For simple two-agent setups this is straightforward. For large group chats, a shared context manager handles this automatically.
Start for free — 10K traces/month, no card needed
AutoGen integration works on all plans including the free tier.