OpenAI released an agentic framework aptly named Agents. What sets this framework apart from others is that it provides a rich set of core building blocks:

  1. Models: Support for all OpenAI Models
  2. Tools: Similar function calling functionality than the one available when using the OpenAI models directly
  3. Knowledge and Memory: Seamless integration with OpenAI’s vector store and Embeddings Anthropic
  4. Guardrails: Run Guardrails checks in parallel to your agent execution which allows for secure execution without slowing down the total agent execution.

Opik’s integration with Agents is just one line of code and allows you to analyse and debug the agent execution flow in our Open-Source platform.

Getting started

First, ensure you have both opik and openai-agents packages installed:

$pip install opik openai-agents

In addition, you can configure Opik using the opik configure command which will prompt you for the correct local server address or if you are using the Cloud platform your API key:

$opik configure

Enabling logging to Opik

To enable logging to Opik, simply add the following two lines of code to your existing OpenAI Agents code:

1from agents import Agent, Runner
2from agents import set_trace_processors
3from opik.integrations.openai.agents import OpikTracingProcessor
4
5set_trace_processors(processors=[OpikTracingProcessor()])
6
7agent = Agent(name="Assistant", instructions="You are a helpful assistant")
8
9result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")
10print(result.final_output)

The Opik integration will automatically track both the token usage and overall cost of each LLM call that is being made. You can also view this information aggregated for the entire agent execution.

Further improvements

OpenAI Agents is still a relatively new framework and we are working on a couple of improvements:

  1. Improved rendering of the inputs and outputs for the LLM calls as part of our Pretty Mode functionality
  2. Improving the naming conventions for spans
  3. Adding the agent execution input and output at a trace level

If there are any additional improvements you would like us to make, feel free to open an issue on our GitHub repository.

Built with