class OpenAIAgentsTracingProcessorTracing processor for the OpenAI Agents SDK.
Traces all intermediate steps of your OpenAI Agent to LangSmith.
Requirements: Make sure to install npm install @openai/agents.
Installing this processor is itself an explicit opt-in to tracing,
so traces will be posted regardless of the LANGSMITH_TRACING env
variable. Any nested traceable() calls made from within an agent
run (e.g. inside a tool handler) will inherit this and also post,
even if LANGSMITH_TRACING is not set.
import { Agent, Runner, function_tool, setTraceProcessors } from "@openai/agents";
import { OpenAIAgentsTracingProcessor } from "langsmith/wrappers/openai_agents";
setTraceProcessors([new OpenAIAgentsTracingProcessor()]);
const getWeather = function_tool({
name: "get_weather",
description: "Get the weather for a city",
parameters: { type: "object", properties: { city: { type: "string" } } },
run: async ({ city }: { city: string }) => `The weather in ${city} is sunny`,
});
const agent = new Agent({
name: "Assistant",
instructions: "You are a helpful assistant",
model: "gpt-4.1-mini",
tools: [getWeather],
});
const result = await Runner.run(agent, "What's the weather in New York?");
console.log(result.finalOutput);