class OpenAIAgentsPlugin(temporalio.client.Plugin, temporalio.worker.Plugin): (source)
Constructor: OpenAIAgentsPlugin(model_params, model_provider)
Temporal plugin for integrating OpenAI agents with Temporal workflows.
Warning
This class is experimental and may change in future versions. Use with caution in production environments.
This plugin provides seamless integration between the OpenAI Agents SDK and Temporal workflows. It automatically configures the necessary interceptors, activities, and data converters to enable OpenAI agents to run within Temporal workflows with proper tracing and model execution.
The plugin: 1. Configures the Pydantic data converter for type-safe serialization 2. Sets up tracing interceptors for OpenAI agent interactions 3. Registers model execution activities 4. Manages the OpenAI agent runtime overrides during worker execution
Example
>>> from temporalio.client import Client >>> from temporalio.worker import Worker >>> from temporalio.contrib.openai_agents import OpenAIAgentsPlugin, ModelActivityParameters >>> from datetime import timedelta >>> >>> # Configure model parameters >>> model_params = ModelActivityParameters( ... start_to_close_timeout=timedelta(seconds=30), ... retry_policy=RetryPolicy(maximum_attempts=3) ... ) >>> >>> # Create plugin >>> plugin = OpenAIAgentsPlugin(model_params=model_params) >>> >>> # Use with client and worker >>> client = await Client.connect( ... "localhost:7233", ... plugins=[plugin] ... ) >>> worker = Worker( ... client, ... task_queue="my-task-queue", ... workflows=[MyWorkflow], ... )
Parameters | |
model | Configuration parameters for Temporal activity execution of model calls. If None, default parameters will be used. |
model | Optional model provider for custom model implementations. Useful for testing or custom model integrations. |
Method | __init__ |
Initialize the OpenAI agents plugin. |
Method | configure |
Configure the Temporal client for OpenAI agents integration. |
Method | configure |
Configure the replayer for OpenAI Agents. |
Method | configure |
Configure the Temporal worker for OpenAI agents integration. |
Async Method | connect |
No modifications to service client |
Method | init |
Set the next client plugin |
Method | init |
Set the next worker plugin |
Async Method | run |
Set the OpenAI Overrides during replay |
Async Method | run |
Run the worker with OpenAI agents temporal overrides. |
Instance Variable | next |
Undocumented |
Instance Variable | next |
Undocumented |
Instance Variable | _model |
Undocumented |
Instance Variable | _model |
Undocumented |
Inherited from Plugin
:
Method | name |
Get the name of this plugin. Can be overridden if desired to provide a more appropriate name. |
ModelActivityParameters | None
= None, model_provider: ModelProvider | None
= None):
(source)
¶
Initialize the OpenAI agents plugin.
Parameters | |
modelModelActivityParameters | None | Configuration parameters for Temporal activity execution of model calls. If None, default parameters will be used. |
modelModelProvider | None | Optional model provider for custom model implementations. Useful for testing or custom model integrations. |
Configure the Temporal client for OpenAI agents integration.
This method sets up the Pydantic data converter to enable proper serialization of OpenAI agent objects and responses.
Parameters | |
config:ClientConfig | The client configuration to modify. |
Returns | |
ClientConfig | The modified client configuration. |
Configure the Temporal worker for OpenAI agents integration.
This method adds the necessary interceptors and activities for OpenAI agent execution: - Adds tracing interceptors for OpenAI agent interactions - Registers model execution activities
Parameters | |
config:WorkerConfig | The worker configuration to modify. |
Returns | |
WorkerConfig | The modified worker configuration. |
temporalio.service.ConnectConfig
) -> temporalio.service.ServiceClient
:
(source)
¶
No modifications to service client
async def run_replayer(self, replayer:
Replayer
, histories: AsyncIterator[ temporalio.client.WorkflowHistory]
) -> AsyncIterator[ AsyncIterator[ WorkflowReplayResult]]
:
(source)
¶
temporalio.worker.Plugin.run_replayer
Set the OpenAI Overrides during replay
temporalio.worker.Plugin.run_worker
Run the worker with OpenAI agents temporal overrides.
This method sets up the necessary runtime overrides for OpenAI agents to work within the Temporal worker context, including custom runners and trace providers.
Parameters | |
worker:Worker | The worker instance to run. |