Skip to main content

Installation

Setup

Python
We recommend using UUIDs for session_id and user_id so traces can be grouped reliably across runs.

Usage

Python
TypeScript
The TypeScript query wrapper traces each query() invocation independently. Unlike the Python client adapter, it does not persist conversation history across separate invocations.

What gets traced

Tool tracing

The adapter injects tracing hooks into the Claude SDK client at initialization:
  • PreToolUse — Creates a TOOL span with the tool’s input arguments
  • PostToolUse — Sets the tool’s output and marks the span as OK (or ERROR if is_error is true)
  • PostToolUseFailure — Records the error and marks the span as ERROR

Extended thinking

Thinking blocks are automatically handled:
  • Thinking content is extracted and stored in metadata as reasoning_summary
  • Thinking-only messages are buffered and combined with the next message’s thinking
  • Thinking blocks are stripped from the visible output

Conversation history

The adapter maintains conversation history across turns on the client instance (_pandaprobe_history), allowing multi-turn tracing with proper context.

Token usage mapping

Example

The Python example exposes two tools via an in-process MCP server and runs a query through ClaudeSDKClient. We trace the agent via ClaudeAgentSDKAdapter:
Python
TypeScript
The Python example produces a trace with: CHAIN (root) → AGENT → LLM (model call) → TOOL (get_weather) → TOOL (get_population) → LLM (final response).