@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
Configuration
Client Options
Projects
Route events to a specific project by passing its slug asprojectId:
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 towrap():
Identifying Users
Useusers.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:Troubleshooting
Events not appearing in dashboard
- Check your write key — Ensure
RAINDROP_WRITE_KEYis set correctly - Call shutdown before exit —
await raindrop.shutdown()flushes all pending data - Enable debug logging — Set
events: { debug: true }to see what’s being shipped
Traces or tool calls missing
- Enable trace debugging — Set
traces: { debug: true }to see span shipping - Check the stream was consumed — Tool call spans are only created when events are iterated
Wrapper not capturing sessions
Ensure you callsessions.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.