Weave for Agents is in public preview. Features, APIs, and the Agents view UI may change before general availability.
Trace Claude Agent SDK agents with Weave
The Weave SDK autopatches the Claude Agent SDK, allowing you to capture traces from your Claude agents with minimal setup. This doc shows how to initialize Weave and then run a Claude agent with MCP tools throughClaudeSDKClient so that Weave automatically traces the conversation, model calls, and tool calls end-to-end.
Prerequisites
- A W&B account and API key set as a
WANDB_API_KEYenvironment variable - An Anthropic API key set as an
ANTHROPIC_API_KEYenvironment variable - Python 3.10+
Install packages
Install the following packages in your developer environment:Initialize Weave in your code
Addweave.init to the project, update your W&B team and project names, and then build an agent the way you normally would.
The following code creates a Claude agent with two MCP math tools and runs it while Weave captures its traces.
weave.init() prints a link to your project when it runs.
For details on viewing Agents data in Weave, see View agent activity.