Reverie adapter for the OpenAI Agents SDK — captures tracing spans as CognitiveEvents
Project description
reverie-adapter-openai
Zero-config Reverie instrumentation for the OpenAI Agents SDK.
Use
import reverie_openai
reverie_openai.auto()
# ... your normal Agents SDK code below ...
from agents import Agent, Runner
agent = Agent(name="my-agent", instructions="...")
result = await Runner.run(agent, "Do the thing.")
That's it. Every span produced by the SDK is translated into a Reverie
CognitiveEvent and posted to the backend (default http://127.0.0.1:8000).
What you get
| SDK span type | CognitiveEvent on start | CognitiveEvent on end |
|---|---|---|
agent |
goal.created |
goal.completed / goal.failed |
function |
tool.called |
tool.returned / tool.failed |
handoff |
subagent.spawned |
subagent.completed |
generation |
— | reasoning.extracted |
response |
— | reasoning.extracted |
guardrail |
— | validation.passed / validation.failed |
| Other types | (wrapped in GenericPayload for forward-compat) |
The full event tree (parentId + depth) is preserved.
Resilience
- Events are posted in batches of up to 50 every ~100ms.
- The emitter runs in a daemon thread with its own asyncio loop — the agent is never blocked.
- If the backend is unreachable, events are dropped silently. The agent always runs to completion.
- A bounded queue (10k events default) protects against memory blow-up.
Configuration
All optional, set as env vars before reverie_openai.auto():
| Var | Default | Description |
|---|---|---|
REVERIE_BACKEND_URL |
http://127.0.0.1:8000 |
Backend base URL |
REVERIE_AGENT_ID |
openai-agent |
Default agent id label |
REVERIE_QUEUE_SIZE |
10000 |
Max queued events |
REVERIE_BATCH_SIZE |
50 |
Max events per POST |
REVERIE_FLUSH_MS |
100 |
Max wait between flushes |
REVERIE_DISABLED |
(unset) | If set to 1, the adapter does nothing |
Install
uv pip install -e ".[dev]"
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reverie_adapter_openai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: reverie_adapter_openai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1beeefd8513f2149998143a79137b6fa1ff7d0944b4b0bacf33b498cf176fb0c
|
|
| MD5 |
019bfc5336aa7932e5820247d640f159
|
|
| BLAKE2b-256 |
44f8582a3a396f892e8ae34f03f04906fcde08c2a494a6605ec84d331e5bc020
|