Skip to Content
Confident AI is free to try . No credit card required.

OpenAI Agents

OpenAI Agents is a lightweight framework for creating agentic workflows using agent swarms, handoffs, and tool use. Confident AI also allows you to trace OpenAI Agent workflows with one line of code.

Quickstart

Install deepeval:

pip install -U deepeval

Login using your API key on Confident AI in the CLI:

deepeval login --confident-api-key YOUR_API_KEY

Trace your OpenAI Agent workflows:

from agents import Agent, Runner, add_trace_processor from deepeval.openai_agents import DeepEvalTracingProcessor add_trace_processor(DeepEvalTracingProcessor()) # Replace with your agent code agent = Agent(name="Assistant", instructions="You are a helpful assistant") result = Runner.run_sync(agent, "Write a haiku about recursion in programming.") print(result.final_output)

DeepEvalTracingProcessor handles both asynchronous workflows and streamed responses.

Loading video...

Tracing OpenAI Agent Example

0 views • 0 days ago
Confident AI Logo
Confident AI
100K subscribers
0

Confident AI’s DeepEvalTracingProcessor automatically traces the following span types:

  • AgentSpanData: OpenAI span for agents
  • FunctionSpanData: OpenAI span for function calls
  • MCPListToolsSpanData: OpenAI span for MCP tool calls
  • GenerationSpanData: OpenAI span for LLM chat completions
  • ResponseSpanData: OpenAI span for LLM response creations
  • HandoffSpanData: OpenAI span for agent handoffs
  • GuardrailSpanData: OpenAI span for guardrails triggered

Logging Threads

Chat conversation threads are also automatically logged to Confident AI when a group_id is provided in your OpenAI Agent workflow.

from agents import Agent, Runner, trace, add_trace_processor from deepeval.openai_agents import DeepEvalTracingProcessor add_trace_processor(DeepEvalTracingProcessor()) thread_id = "unique_thread_id" async def main(): agent = Agent(name="Assistant", instructions="Reply very concisely.") with trace(workflow_name="Conversation", group_id=thread_id): # First turn result = await Runner.run(agent, "What city is the Golden Gate Bridge in?") print(result.final_output) # San Francisco # Second turn new_input = result.to_input_list() + [{"role": "user", "content": "What state is it in?"}] result = await Runner.run(agent, new_input) print(result.final_output) # California
Last updated on