Skip to main content
Claude Agent SDK is Anthropic’s Python SDK for building AI agents powered by Claude Code. It gives agents access to built-in tools like Bash, Read, Write, and Glob for autonomous task execution. HoneyHive integrates with the Claude Agent SDK via the OpenInference instrumentor, automatically capturing agent runs, tool calls, and multi-turn conversations.

Quick Start

Add HoneyHive tracing in just 4 lines of code. Initialize the tracer and instrumentor, and all agent activity is automatically traced.
To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see Tracer Initialization.

Compatibility

What Gets Traced

The instrumentor automatically captures:
  • Agent runs - Every agent invocation with inputs and outputs
  • Tool executions - Built-in tool calls (Bash, Read, Write, Glob) with arguments and results
  • Multi-turn conversations - Session continuity across turns with ClaudeSDKClient
  • Token usage and cost - Model token counts and cost per request
No manual instrumentation required.

Example: Single Query with Tools

The query() function runs a one-off agent session. The agent can use built-in tools to complete tasks autonomously:
permission_mode="bypassPermissions" allows unrestricted tool use without interactive prompts. Use only in sandboxed or non-interactive environments.

Example: Multi-Turn Conversation

ClaudeSDKClient maintains session continuity across multiple turns. The agent remembers context from previous interactions:
In HoneyHive, you’ll see each turn as a separate agent span with tool calls nested underneath.

Troubleshooting

Traces not appearing

  1. Check environment variables - Ensure HH_API_KEY is set
  2. Pass the tracer provider - The instrumentor must receive tracer_provider=tracer.provider:
  1. Import after instrumenting - Import claude_agent_sdk after calling instrument(). The instrumentor patches module-level functions, so importing before patching captures the original unpatched references:
  1. Flush before exit - Call tracer.force_flush() before your process exits. Without this, buffered spans may be silently dropped in short-lived scripts:
  1. Check Anthropic credentials - Ensure ANTHROPIC_API_KEY is set

Enrich Your Traces

Add user IDs and custom metadata to Claude Agent SDK traces

Custom Spans

Create spans for business logic around agent calls

Distributed Tracing

Trace agents across service boundaries

Resources