Installation
- pip
- uv
- npm
- yarn
- pnpm
Setup
- Python
- TypeScript
Python
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
TOOLspan with the tool’s input arguments - PostToolUse — Sets the tool’s output and marks the span as OK (or
ERRORifis_erroris 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 throughClaudeSDKClient. We trace the agent via ClaudeAgentSDKAdapter:
Python
TypeScript
CHAIN (root) → AGENT → LLM (model call) → TOOL (get_weather) → TOOL (get_population) → LLM (final response).
