Skip to main content
The @raindrop-ai/claude-managed-agents package automatically instruments Claude Managed Agents sessions to capture events and traces. Wrap the Anthropic client once, then use it normally — session creation, event streaming, and tool calls are tracked automatically. Features:
  • No OpenTelemetry setup required
  • Automatic tool call tracing (bash, file operations, web search, grep, MCP tools, custom tools)
  • Token usage tracking with cache creation/read breakdown
  • Per-session context overrides (userId, convoId, properties)

Installation

Quick Start

The wrapped client is a transparent proxy — all methods work identically to the original Anthropic client. Session creation, event streaming, and tool calls are instrumented automatically.

Configuration

Client Options

Projects

Route events to a specific project by passing its slug as projectId:
This sets the X-Raindrop-Project-Id header on every event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. Single-project orgs need nothing new.

Per-Session Context

Override defaults for specific sessions using the second argument to wrap():

Identifying Users

Use users.identify to associate traits with a user:

Signals (Feedback)

Track user feedback on agent sessions:

Signal Types


Manual Event Updates

Update events after they’re created:
Events are automatically finalized when the session stream completes. Use finish() only when you need to force immediate shipping.

Flush & Shutdown

Always flush before your process exits to ensure all data is sent:

What Gets Captured

Each managed agent session produces:
  • One Raindrop event with input (user message), output (agent response), model, and token counts
  • A root trace span (managed_agent.session) with the session ID
  • Child trace spans for each tool call (managed_agent.toolCall, managed_agent.mcpToolCall, managed_agent.customToolCall)
  • Token usage aggregated across all model requests, including cache creation/read tokens
  • Session errors captured in event properties

Debugging

Enable debug logging to troubleshoot issues:
Or via environment variable:

Troubleshooting

Events not appearing in dashboard

  1. Check your write key — Ensure RAINDROP_WRITE_KEY is set correctly
  2. Call shutdown before exitawait raindrop.shutdown() flushes all pending data
  3. Enable debug logging — Set events: { debug: true } to see what’s being shipped

Traces or tool calls missing

  1. Enable trace debugging — Set traces: { debug: true } to see span shipping
  2. Check the stream was consumed — Tool call spans are only created when events are iterated

Wrapper not capturing sessions

Ensure you call sessions.create() on the wrapped client, not the original. Only sessions created through the wrapped client are tracked.

Self Diagnostics (Optional)

Self Diagnostics lets your agent proactively report its own issues — capability gaps, missing context, persistent tool failures — back to your team as Raindrop signals. A custom tool (__raindrop_report) is automatically injected into the agent definition. When the agent calls it, the wrapper ships a signal, auto-responds, and filters the tool call from the consumer stream. The agent never mentions the tool to the user.
When invoked, the signal appears in Raindrop with the category and detail:
The agent must be created through the wrapped client (wrapped.beta.agents.create()), not the original. Otherwise the reporting tool won’t be injected.