Skip to content

OpenAI Agents

Trace agent runs, tool calls, and handoffs from the OpenAI Agents SDK.

Terminal window
pip install "axonpush[openai-agents]"

The OpenAI Agents SDK is async-only, so use AsyncAxonPush:

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)

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)

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)
EventWhen
agent.run.startAgent run begins
agent.run.endAgent run completes
tool.*.startTool call begins
tool.*.endTool call completes
agent.handoffAgent hands off to another agent