Braintrust supports AgentScope 1.x and 2.x, and requires AgentScope v1.0.0 or later. AgentScope 2.x requires Python 3.11 or later.
Setup
Install the Braintrust SDK and AgentScope, then set your API keys. The examples below use OpenAI.1
Install packages
2
Set environment variables
.env
Auto-instrumentation
To trace AgentScope alongside Braintrust’s other supported libraries, callbraintrust.auto_instrument() before importing AgentScope. Because AgentScope uses from agentscope... import style imports, the call must come first so the patches are in place.setup_agentscope() instead of braintrust.auto_instrument(). It initializes a Braintrust logger when one isn’t already active.What Braintrust traces
Braintrust traces AgentScope runs as nested spans that mirror the actual execution flow. Captured spans:- Agent run spans (
<agent>.reply, such asFriday.reply), with the call input, agent class, and response. Both the 1.xAgentBase.__call__and 2.xAgent.replypaths are instrumented. - Pipeline spans (
sequential_pipeline.runandfanout_pipeline.run), with the names of the participating agents. Child agent, tool, and model spans nest underneath. - Tool execution spans (
<tool>.execute, such asexecute_python_code.execute), with the tool call, toolkit class, and output, including streamed tool output. - Model call spans (
<provider>.call, such asOpenAIChat.call), with messages, tools, and model metadata (model name, provider, and request parameters); response content and token usage (prompt, completion, and total) on completion. - Streaming model responses and tool outputs, aggregated into the final span output, with token metrics on model spans.
- Errors on failed agent runs, pipelines, tool calls, and model calls.