Files
Andrew MaguireandGitHub 3a1e0899ca feat(ai): add OpenAI Agents SDK tracing support (#3377)
* feat(ai): add OpenAI Agents SDK tracing support

Add PostHogTracingProcessor implementing the TracingProcessor interface
from @openai/agents-core to capture agent traces, spans, and LLM
generations as PostHog LLM analytics events.

Supports all span types: generation, response, function/tool, agent,
handoff, guardrail, custom, transcription, speech, speech_group, and
MCP tools. Includes privacy mode, personless mode, error categorization,
latency tracking, and an `instrument()` one-liner for easy setup.

Available as `@posthog/ai/openai-agents`.

* fix(ai): normalize input roles for OpenAI Agents SDK response spans

Add role fields to function_call (role=assistant) and function_call_result
(role=tool) items in $ai_input. The OpenAI Responses API format omits
roles on these items, causing PostHog's trace viewer to default them to
"user" messages.

* fix: lint errors in openai-agents processor and tests

* fix: address PR review feedback

- Reverse property spread order so built-in $ai_* properties can't be
  overridden by user properties
- Remove eval() from examples, replace with safe stubs
- Switch instrument() from require() to dynamic import() for ESM compat
- Forward speech_group input to event properties
- Collapse error categorization tests into it.each

* fix: address P1/P2 review findings

- Peer dep is now @openai/agents (what users install), runtime import
  stays on @openai/agents-core (available transitively, lighter init)
- Examples now await instrument() to prevent race with first run()
- Updated JSDoc to show await pattern

* refactor(ai): align openai-agents processor with SDK patterns

- Add $ai_lib and $ai_lib_version to all events (matches other integrations)
- Use shared withPrivacyMode from utils.ts instead of private duplicate

* fix(ai): address openai agents review feedback
2026-04-14 11:49:00 +01:00

11 lines
187 B
JSON

{
"compilerOptions": {
"target": "ES2022",
"module": "node16",
"moduleResolution": "node16",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}