OpenAI Agents SDK Integration with Future AGI Tracing

Trace OpenAI Agents SDK runs, model calls, tool calls and handoffs in Future AGI.

Trace an OpenAI Agents SDK run and its model calls in Future AGI. Agents that use tools or handoffs also produce spans for those operations.

1. Installation

Use Python 3.10 through 3.13 and install the traceAI package.

pip install traceAI-openai-agents

2. Set Environment Variables

Set up your environment variables to authenticate with both FutureAGI and OpenAI.

import os

os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"

3. Initialize Trace Provider

Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines.

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="openai_project",
)

4. Instrument your Project

Instrument your project before running the agent. By default, exclusive_processor=True replaces the SDK’s existing trace processors, including its default OpenAI tracing exporter. To retain existing processors, pass exclusive_processor=False; those processors will continue to receive traces at their configured destinations. This setting changes telemetry export, not the model API calls.

from traceai_openai_agents import OpenAIAgentsInstrumentor

OpenAIAgentsInstrumentor().instrument(tracer_provider=trace_provider)

5. Interact with OpenAI Agents

The SDK includes model inputs/outputs and tool-call payloads in traces by default. The example uses RunConfig(trace_include_sensitive_data=False) to omit those payloads while retaining operation spans (OpenAI tracing privacy controls). This is not a general scrubber for custom metadata, span names or error details; use data approved for tracing. For additional exporter-side controls, see trace masking.

from agents import Agent, RunConfig, Runner

agent = Agent(name="Assistant", instructions="You are a helpful assistant")
result = Runner.run_sync(
    agent,
    "Write a haiku about recursion in programming.",
    run_config=RunConfig(trace_include_sensitive_data=False),
)

print(result.final_output)
trace_provider.force_flush()

Open openai_project in Future AGI to inspect the agent trace.

Was this page helpful?

Questions & Discussion