Skip to main content

raindrop-openai-agents

Raindrop integration for the OpenAI Agents SDK (Python). Implements a TracingProcessor that automatically captures agent runs, LLM generations, tool calls, and handoffs and ships them to Raindrop.

Installation

pip install raindrop-openai-agents openai-agents

Quick Start

from raindrop_openai_agents import RaindropOpenAIAgents
from agents import Agent, Runner

raindrop = RaindropOpenAIAgents(
    api_key="your-write-key",
    user_id="user-123",
)
# Processor is auto-registered with the global trace provider

agent = Agent(name="Assistant", model="gpt-4o", instructions="Be helpful")
result = Runner.run_sync(agent, "Hello!")
print(result.final_output)

raindrop.flush()

Factory Function (Legacy)

The create_raindrop_openai_agents() factory is still available and now returns a RaindropOpenAIAgents instance:

from raindrop_openai_agents import create_raindrop_openai_agents

raindrop = create_raindrop_openai_agents(api_key="your-write-key", user_id="user-123")
raindrop.flush()

What Gets Captured

  • Agent runs — trace-level events with workflow name
  • LLM generations — model, input messages, output text, token usage
  • Tool calls — individual tool spans with name, input, output, duration, and error tracking via the Interaction API
  • Finish reason — extracted from response status or generation output (ai.finish_reason)
  • Extended token categories — cached tokens (ai.usage.cached_tokens) and reasoning/thoughts tokens (ai.usage.thoughts_tokens) for OpenAI o1/o3 models
  • Errors — error type and message captured in event properties (never interferes with agent execution)

Projects

Route events to a specific project by passing its slug as project_id:

raindrop = RaindropOpenAIAgents(
    api_key="your-write-key",
    project_id="support-prod",
)

project_id 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. The same option is accepted by the create_raindrop_openai_agents(...) factory. Invalid slugs are ignored with a warning and no header is sent.

API Reference

RaindropOpenAIAgents(api_key, user_id=None, convo_id=None, project_id=None, tracing_enabled=True, bypass_otel_for_tools=True, disable_auto_instrument=True, debug=False)

Parameter Type Default Description
api_key Optional[str] None Raindrop API key (omit to disable telemetry)
user_id Optional[str] "unknown" Default user identifier for all events
convo_id Optional[str] None Group events into a conversation
project_id Optional[str] None Route events to a specific project (slug); omit for the default Production project
tracing_enabled bool True Enable OTEL-based tracing
bypass_otel_for_tools bool True Bypass OTEL instrumentation for tool calls
disable_auto_instrument bool True Library auto-instrumentation is opt-in (see below)
debug bool False Enable verbose debug logging

Library auto-instrumentation is opt-in

As of 0.0.4, disable_auto_instrument defaults to True: the integration no longer lets Traceloop monkey-patch every LLM client library it recognizes in your process (including the OpenAI client the Agents SDK itself drives). The tracing processor captures input/output, token usage, model name, tool calls, and handoffs directly from Agents SDK trace events, so no library patching is needed for full dashboards.

If you specifically want LLM-call-level spans from library instrumentation and have verified compatibility in your environment, opt back in with disable_auto_instrument=False.

Properties

Name Type Description
processor RaindropTracingProcessor The underlying tracing processor (for manual registration)

Methods

Method Description
flush() Flush buffered events to Raindrop
shutdown() Flush events and release resources
identify(user_id, traits=None) Identify a user with optional traits
track_signal(event_id, name, signal_type, *, timestamp, properties, attachment_id, comment, after, sentiment) Attach a signal (feedback, label, etc.) to an existing event

Tool Call Tracking

Tool calls made by agents are automatically captured as individual tool spans. Each span includes:

  • Name — the function/tool name
  • Input — the arguments passed to the tool
  • Output — the tool's return value
  • Duration — execution time in milliseconds (computed from SDK span timestamps)
  • Error — error message if the tool call failed

Tool spans are tracked via the Raindrop Interaction API (interaction.track_tool()), providing full visibility into agent tool usage alongside LLM generation data.

Extended Token Categories

For OpenAI o1/o3 models that report detailed token breakdowns, the integration captures:

Property Source Description
ai.usage.cached_tokens input_tokens_details.cached_tokens or prompt_tokens_details.cached_tokens Tokens served from cache
ai.usage.thoughts_tokens output_tokens_details.reasoning_tokens or completion_tokens_details.reasoning_tokens Tokens used for internal reasoning

These are reported alongside the standard ai.usage.prompt_tokens and ai.usage.completion_tokens.

Debug Mode

raindrop = RaindropOpenAIAgents(
    api_key="your-write-key",
    debug=True,  # enable verbose logging
)

Identify Users

raindrop.identify("user-42", traits={"plan": "pro", "company": "Acme"})

Track Signals

raindrop.track_signal(
    event_id="evt_abc123",
    name="thumbs_up",
    signal_type="feedback",
    sentiment="POSITIVE",
    comment="Great answer!",
)

Flush & Shutdown

raindrop.flush()     # flush pending data
raindrop.shutdown()  # flush + release resources

Known Limitations

  • Multi-response traces — in multi-agent workflows, only the last response's data survives per trace.

Full Documentation

docs.raindrop.ai/integrations/openai-agents

Application Git metadata

RaindropOpenAIAgents(...) and create_raindrop_openai_agents(...) accept the keyword-only app_git option. It defaults to True: explicit Raindrop Git environment or deployment context is applied immediately, and the base SDK may perform one bounded background local-Git lookup from the process working directory. Event capture, flush, and shutdown never wait for that lookup. Pass False to disable enrichment, or pass an AppGitOptions mapping with commit_sha, commit_dirty, branch, source_directory, detect_branch, and/or auto_detect. Automatic branch discovery remains opt-in through detect_branch=True (or RAINDROP_GIT_DETECT_BRANCH=true).

For an ordinary in-process application, the process working directory is treated as the application-under-test checkout. A remote, coding, workflow, or observer process must not rely on its own checkout: pass app_git=False, provide explicit revision values, or set source_directory to the actual application checkout. Canonical per-operation properties remain authoritative. When supplying client=, configure app_git while constructing that Raindrop client; the supplied client is authoritative and the wrapper's app_git argument does not reconfigure it.

Release order is deliberate: first publish the base SDK feature, then publish the wrapper feature release with its minimum dependency coordinated to that base release. The existing raindrop-ai lower bound remains compatible, but application Git metadata is unavailable on an older core and must not be claimed complete until the base is upgraded. Until coordination assigns a released version, the wrapper checks for an explicit base app_git parameter and omits the option when unsupported. Explicit non-default configuration is debug-logged and omitted. Unsupported app_git is determined by signature inspection before construction, not by retrying initialization after a TypeError; Git configuration adds no initialization attempts and does not change any existing framework-specific initialization fallback.

Testing

cd packages/openai-agents-python
pip install -e ".[dev]"
python -m pytest tests/ -v   # unit tests (no external services)

End-to-end behavior is verified by the cross-SDK conformance harness. This package ships a thin conformance driver at conformance/driver.py that maps the shared scenario corpus onto the wrapper's public API; known gaps are tracked as ticket-linked entries in conformance/failures.txt. The fault lane runs on every PR touching packages/*-python/** (.github/workflows/conformance-wrappers-python.yml) against a local capture server; the prod lane verifies delivery by reading back through the public Query API. The harness is pinned by commit SHA (HARNESS_REF). See the harness docs: HOW-IT-WORKS · AGENTS · README.

License

MIT

Release files for raindrop-openai-agents 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for raindrop-openai-agents 0.0.11
File Size Uploaded
raindrop_openai_agents-0.0.11.tar.gz 40.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for raindrop-openai-agents 0.0.11
File Interpreter ABI Platform
raindrop_openai_agents-0.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 59.7 kB

Release files / raindrop_openai_agents-0.0.11.tar.gz

Download URL raindrop_openai_agents-0.0.11.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
27c9a7efe55775e83f88c425608373e33c4d34eb7cbddd744e83cc5cdfb993a5
BLAKE2b-256 checksum
How to use checksums
e5966151c85e010837ca05317508a6bca969a99f1b4936f1cb5c3430c5d7799f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / raindrop_openai_agents-0.0.11-py3-none-any.whl

Download URL raindrop_openai_agents-0.0.11-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a0f3f3063bd435e401ee5e1777b2dae503a9dd63574e9b5007370a96645d8d6
BLAKE2b-256 checksum
How to use checksums
bc4158020cd92019d1b2d4ee2032ee38fe82f0ce1a745511324ffdd0aafc18b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.0.11 This release

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page