module documentation

Initialize Temporal OpenAI Agents overrides.

Function set_open_ai_agent_temporal_overrides Configure Temporal-specific overrides for OpenAI agents.
@contextmanager
def set_open_ai_agent_temporal_overrides(**kwargs): (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

Example usage:
with set_open_ai_agent_temporal_overrides(
start_to_close_timeout=timedelta(seconds=30), retry_policy=RetryPolicy(maximum_attempts=3)
):
# Initialize Temporal client and worker here client = await Client.connect("localhost:7233") worker = Worker(client, task_queue="my-task-queue") await worker.run()
Parameters
**kwargsAdditional arguments to pass to the TemporalOpenAIRunner constructor. These arguments are forwarded to workflow.execute_activity_method when executing model calls. Common options include: - start_to_close_timeout: Maximum time for the activity to complete - schedule_to_close_timeout: Maximum time from scheduling to completion - retry_policy: Policy for retrying failed activities - task_queue: Specific task queue to use for model activities
Returns
A context manager that yields the configured TemporalTraceProvider.