OpenAI Agents
Trace agent runs, tool calls, and handoffs from the OpenAI Agents SDK.
Installation
bash
pip install "axonpush[openai-agents]"Setup
The OpenAI Agents SDK is async-only, so use AsyncAxonPush:
python
import os
from axonpush import AsyncAxonPush
from axonpush.integrations.openai_agents import AxonPushRunHooks
client = AsyncAxonPush(
api_key=os.environ["AXONPUSH_API_KEY"],
tenant_id=os.environ["AXONPUSH_TENANT_ID"],
base_url=os.environ.get("AXONPUSH_BASE_URL", "https://api.axonpush.xyz"),
)
hooks = AxonPushRunHooks(client=client, channel_id=1)Usage
Pass hooks to Runner.run():
python
from agents import Agent, Runner
agent = Agent(name="research-agent", instructions="You are a research assistant.")
result = await Runner.run(agent, "Find papers on multi-agent systems", hooks=hooks)Cleanup
Close the client when done:
python
await client.close()Or use a context manager:
python
async with AsyncAxonPush(...) as client:
hooks = AxonPushRunHooks(client=client, channel_id=1)
result = await Runner.run(agent, input, hooks=hooks)Events Traced
| Event | When |
|---|---|
agent.run.start | Agent run begins |
agent.run.end | Agent run completes |
tool.*.start | Tool call begins |
tool.*.end | Tool call completes |
agent.handoff | Agent hands off to another agent |