OpenAI Agents
Trace agent runs, tool calls, and handoffs from the OpenAI Agents SDK.
Installation
Section titled “Installation”pip install "axonpush[openai-agents]"The OpenAI Agents SDK is async-only, so use AsyncAxonPush:
import osfrom axonpush import AsyncAxonPushfrom 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)Pass hooks to Runner.run():
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
Section titled “Cleanup”Close the client when done:
await client.close()Or use a context manager:
async with AsyncAxonPush(...) as client: hooks = AxonPushRunHooks(client=client, channel_id=1) result = await Runner.run(agent, input, hooks=hooks)Events Traced
Section titled “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 |