Setup
Install the Braintrust SDK and AutoGen with the OpenAI extension (used in the examples below), then set your Braintrust and OpenAI API keys.1
Install packages
2
Set environment variables
.env
Auto-instrumentation
To trace AutoGen alongside Braintrust’s other supported libraries, callbraintrust.auto_instrument() before creating AutoGen agents or teams.setup_autogen() instead of braintrust.auto_instrument().What Braintrust traces
Braintrust patches AutoGen’s chat agent, team, andFunctionTool entry points (autogen-agentchat>=0.7.0). Captured spans:- Agent run spans (
<agent>.runand<agent>.run_stream), with task input, agent metadata (name, description, class), output, and errors. Emitted for both direct agent calls and agents running inside a team (such asRoundRobinGroupChat). - Team run spans (
<team>.runand<team>.run_stream), with task input, team metadata (name, description, class, participant names), output, and errors. - Tool call spans (
<tool>.run) forFunctionToolinvocations, with arguments, tool metadata (name, description, class), output, and errors. - Streaming events aggregated into the parent span’s output, not emitted as per-chunk child spans.
- Parent-child nesting: agent spans nest under any enclosing team span, and LLM and tool call spans nest under the agent that issued them. With
auto_instrument(), provider LLM calls inherit this nesting automatically.