Skip to main content

Google Colab

The OpenAI Agents SDK handles the agent loop, tool calls, and handoffs for you, and its OpenInference instrumentor traces all of it automatically. This guide builds a small math-solving agent, traces its activity in Arize AX, then benchmarks it with a dataset and an LLM-as-a-judge experiment. You’ll go through the following steps:
  • Create an agent using the OpenAI Agents SDK
  • Trace the agent activity
  • Create a dataset to benchmark performance
  • Run an experiment to evaluate agent performance using LLM as a judge
The build and tracing steps are shown in both Python and TypeScript. The dataset and experiment steps use the Arize Python SDK.
Building without the Agents SDK? If you assemble the agent loop yourself on the plain OpenAI SDK, see Trace an Agent Built with the OpenAI SDK, which covers the manual spans you add to make that loop observable.

Get your Arize credentials

Create a tracing project from Projects → New Tracing Project. The setup page shows the credentials you need: copy your Space ID and click Create API Key to generate a key. Save the key somewhere safe. You’ll also need an OpenAI API key. You’ll plug all of these into the steps below.
New Tracing Project setup page showing Space ID and Create API Key

Initial setup

1

Install libraries

2

Set up keys

Enter the Space ID and API key you copied, along with your OpenAI key.
3

Set up tracing

The OpenInference instrumentor registers against the Agents SDK, so agent invocations, tool calls, handoffs, and the underlying LLM calls all become spans.

Create your first agent

You’ll set up a basic agent that solves math problems, with a function tool that evaluates equations and an agent that can call it.
Use the Runner class to run the agent and get the final output.
Now that the agent runs, evaluate whether it responded correctly.
The dataset and experiment steps below use the Arize Python SDK. If you built your agent in TypeScript, its traces are already in Arize AX; run the evaluation from a Python environment, or use the online evaluations workflow in the product.

Evaluate the agent

Agents can go wrong in several ways:
  1. Tool call accuracy: did the agent choose the right tool with the right arguments?
  2. Tool call results: did the tool respond with the right results?
  3. Agent goal accuracy: did the agent accomplish the stated goal and reach the right outcome?
You’ll set up a simple evaluator that checks whether the agent’s response is correct. To go further, see the types of agent evals. Set up the evaluation by defining a task function, an evaluator, and a dataset.
Next, create the evaluator.

Create synthetic dataset of questions

Using the template below, generate a dataframe of 25 questions to test the math-solving agent.
Next, upload this dataset and run the agent over it as an experiment.

Create an experiment

With the dataset generated above, use experiments to track changes across models, prompts, and parameters for the agent. Create this dataset and upload it to the platform.
Now run the experiment. dry_run=True executes the task and evaluators locally without uploading the results, which is handy for a quick check. Remove it to persist the experiment and view it in Arize AX.