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, letting you capture traces from your Claude agents with minimal setup. This doc shows how to initialize Weave and run a Claude agent with MCP tools throughClaudeSDKClient. Weave automatically traces the conversation, model calls, and tool calls end-to-end. When you’re done, you can view a complete trace of the agent’s query, model responses, and tool invocations in the Agents view of your project.
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. Theweave package captures traces, and claude-agent-sdk provides the agent runtime.
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. weave.init enables the autopatching that captures traces from the Claude Agent SDK.
The following code creates a Claude agent with two MCP math tools and runs it while Weave captures the traces.
weave.init() prints a link to your project. Open the link to inspect the captured traces for the agent’s query, model responses, and tool calls.
For details about viewing Agents data in Weave, see View agent activity.