Skip to main content
The Claude Agent SDK enables you to quickly build agent applications powered by Claude. You can integrate CoreWeave Agent Lens into your Claude agents to automatically trace their calls, including agent queries, model responses, tool use, and multi-turn conversations.
This integration uses the Weights & Biases Weave SDK (weave), because the CoreWeave Forge SDK doesn’t support this framework yet. Traces you send with Weave appear in Agent Lens, because both products share the same trace data.

Trace Claude Agent SDK agents with Agent Lens

The Weave SDK autopatches the Claude Agent SDK for Python, letting you capture traces from your Claude agents with minimal setup.This guide shows how to initialize Weave and run a multi-turn Claude agent with MCP tools through query(). Agent Lens automatically traces the conversation, model calls, and tool calls end-to-end.

Prerequisites

  • A CoreWeave Forge account and API key set as a WANDB_API_KEY environment variable.
  • An Anthropic API key set as an ANTHROPIC_API_KEY environment variable.
  • Python 3.10+.

Install packages

Install the following packages in your developer environment. The weave package captures traces, claude-agent-sdk provides the agent runtime, and the remaining packages support the example tool.

Initialize Agent Lens in your code

Add weave.init to the project, update your Forge 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.This example defines a wikipedia_search MCP tool and runs a three-turn conversation. Each turn is a separate query() call, but later turns pass resume with the first turn’s session ID so that all turns group as one conversation in the Agent Lens Conversations tab. The first two turns trigger Wikipedia lookups, and the third uses the previous conversation context to produce a summary without a tool call.
Each query() call produces an invoke_agent root span. Because the follow-up turns resume the same session, Weave stamps the same gen_ai.conversation.id on all spans, and Agent Lens groups them as one conversation. ResultMessage.session_id carries the ID to reuse, and resume accepts None on the first turn, which starts a new session.Without resume, each turn starts its own session and appears as a separate conversation. ClaudeSDKClient is the exception: it holds one session open for the lifetime of the async with block, so turns you send through the same client are already grouped. Weave patches both paths.

View your traces in Agent Lens

After the script runs, weave.init() prints a link to your project in Weave. The same traces appear in Agent Lens, because both products share the same trace data. To view them in Agent Lens:
  1. Navigate to CoreWeave Forge and select Agent Lens from the product menu.
  2. Select your project.
  3. In the Agent Lens side menu, select Conversations, and then select your conversation.
Each turn renders as an invoke_agent span with nested chat and execute_tool spans. Each span shows its input, model, output, token usage, and tool results. For more information, see View agent activity.
Last modified on September 30, 2026