Skip to main content
Bitfab integrates with the OpenAI Agents SDK via a tracing processor that automatically captures agent runs, tool calls, handoffs, and guardrails as traced spans - no manual withSpan or @span decorators needed. To make those runs replayable, a thin run wrapper (wrapRun / wrap_run) records a root span carrying the run input; see Replayable runs with the run wrapper. Canonical signatures: TypeScript reference · Python reference

Supported Languages

Quick Start

Use addTraceProcessor / add_trace_processor (shown above) to add the Bitfab processor alongside any existing ones. The OpenAI Agents SDK also exposes setTraceProcessors / set_trace_processors, which replaces the entire processor list, including the SDK’s default exporter to the OpenAI platform dashboard. Only use the set form if you want Bitfab to be the sole destination and intend to disable OpenAI’s own tracing.

TypeScript

Installation

Method Signature

Parameters: None. Returns: A BitfabOpenAITracingProcessor instance that implements the OpenAI Agents SDK TracingProcessor interface.

Usage

What Gets Captured

The processor implements the TracingProcessor interface and captures: Span types from the OpenAI Agents SDK (agent, function, generation, guardrail, handoff, etc.) are mapped to Bitfab span data automatically.

Nesting with Core Tracing

If you wrap an agent invocation with withSpan, the OpenAI Agents spans nest as children:

Error Handling

All processor callbacks are wrapped in try/catch - errors are logged but never thrown. Your agent execution is never affected by tracing failures.

Python

Installation

The openai-tracing extra installs openai-agents as a dependency.

Method Signature

Parameters: None. Returns: A BitfabOpenAITracingProcessor instance that implements the OpenAI Agents SDK TracingProcessor interface.

Usage

What Gets Captured

Same as TypeScript - the processor implements the TracingProcessor interface:

Nesting with Core Tracing

Error Handling

All processor callbacks are wrapped in try/except - errors are logged but never raised. Your agent execution is never affected by tracing failures. Traces flush automatically via atexit hook.

Replayable runs with the run wrapper

The tracing processor captures the agent run for observability, but the processor alone records a root span with no input. The OpenAI Agents agent span is the trace root, and the run input never lands on it (only a response child span carries the model-request input). Replay re-runs the trace’s root span against its recorded input, so a processor-only trace would replay with nothing to feed it. The run wrapper makes a run replayable with no hand-written root. getOpenAiAgentHandler(key).wrapRun (TS) / get_openai_agent_handler(key).wrap_run (Python) is a drop-in for the run call: it opens a keyed root span carrying the run input and final output, and the processor’s auto-captured spans nest underneath. Keep the processor registered for the internals; swap the run call for the wrapper.
The wrapper’s root carries the serializable run input, so replay re-runs each historical input through your code by key - no @span/withSpan-decorated function needs to exist. Rebuild any runtime environment inside the callable (agent construction, tools, API keys); use no-op substitutes for side-effectful wiring. Alternative: a hand-written root. When there is meaningful work around the run (input prep, orchestration, post-processing), wrap the whole workflow in a withSpan / @span root that takes the workflow input (the same wrap shown in Nesting with Core Tracing). The processor’s spans nest underneath it, and replay re-runs the root against its recorded input. Full details in the Python SDK and TypeScript SDK Replay sections.

Streaming runs

Streamed runs are also traced: the run input lands on the root span and the final output is captured once the stream drains, so first-byte latency is untouched.
In TypeScript, wrapRun returns the streamed run result (drained by the caller) and records the root in the background once it completes. In Python, wrap_run_streamed is itself an async generator that yields each event from Runner.run_streamed(...).stream_events(); the span stays open for the whole iteration so the processor’s spans nest beneath the root.
To replay a recorded run as a regression with bitfab.replay(), use the non-streaming wrapper (wrapRun / wrap_run), which replay re-runs directly. bitfab.replay() does not drive the Python wrap_run_streamed async generator.