package documentation

Support for using the OpenAI Agents SDK as part of Temporal workflows.

This module provides compatibility between the OpenAI Agents SDK and Temporal workflows.

Warning

This module is experimental and may change in future versions. Use with caution in production environments.

Module temporal_openai_agents Initialize Temporal OpenAI Agents overrides.
Module workflow Workflow-specific primitives for working with the OpenAI Agents SDK in a workflow context
Module _heartbeat_decorator No module docstring; 0/1 type variable, 1/2 function documented
Module _invoke_model_activity A temporal activity that invokes a LLM model.
Module _model_parameters Parameters for configuring Temporal activity execution for model calls.
Module _openai_runner No module docstring; 1/1 class documented
Module _temporal_model_stub No module docstring; 0/1 variable, 1/1 class documented
Module _temporal_trace_provider Provides support for integration with OpenAI Agents SDK tracing across workflows
Module _trace_interceptor Adds OpenAI Agents traces and spans to Temporal workflows and activities.

From __init__.py:

Class ModelActivity Class wrapper for model invocation activities to allow model customization.
Class ModelActivityParameters Parameters for configuring Temporal activity execution for model calls.
Class OpenAIAgentsTracingInterceptor Interceptor that propagates OpenAI agent tracing context through Temporal workflows and activities.
Class TestModel Test model for use mocking model responses.
Class TestModelProvider Test model provider which simply returns the given module.
Function set_open_ai_agent_temporal_overrides Configure Temporal-specific overrides for OpenAI agents.
@contextmanager
def set_open_ai_agent_temporal_overrides(model_params: ModelActivityParameters | None = None, auto_close_tracing_in_workflows: bool = False): (source) ΒΆ

Configure Temporal-specific overrides for OpenAI agents.

Warning

This API is experimental and may change in future versions. Use with caution in production environments. Future versions may wrap the worker directly instead of requiring this context manager.

This context manager sets up the necessary Temporal-specific runners and trace providers for running OpenAI agents within Temporal workflows. It should be called in the main entry point of your application before initializing the Temporal client and worker.

The context manager handles: 1. Setting up a Temporal-specific runner for OpenAI agents 2. Configuring a Temporal-aware trace provider 3. Restoring previous settings when the context exits

Parameters
model_params:ModelActivityParameters | NoneConfiguration parameters for Temporal activity execution of model calls.
auto_close_tracing_in_workflows:boolIf set to true, close tracing spans immediately.
Returns
A context manager that yields the configured TemporalTraceProvider.