diff --git a/temporalio/contrib/openai_agents/__init__.py b/temporalio/contrib/openai_agents/__init__.py index eeefbff8c..6d64b0b07 100644 --- a/temporalio/contrib/openai_agents/__init__.py +++ b/temporalio/contrib/openai_agents/__init__.py @@ -2,10 +2,6 @@ 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. """ from temporalio.contrib.openai_agents._mcp import ( diff --git a/temporalio/contrib/openai_agents/_temporal_openai_agents.py b/temporalio/contrib/openai_agents/_temporal_openai_agents.py index 16a1403ef..39168d0fd 100644 --- a/temporalio/contrib/openai_agents/_temporal_openai_agents.py +++ b/temporalio/contrib/openai_agents/_temporal_openai_agents.py @@ -44,33 +44,10 @@ @contextmanager -def set_open_ai_agent_temporal_overrides( +def _set_open_ai_agent_temporal_overrides( model_params: ModelActivityParameters, start_spans_in_replay: bool = False, ): - """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 - - Args: - model_params: Configuration parameters for Temporal activity execution of model calls. - start_spans_in_replay: If set to true, start spans even during replay. Primarily used for otel integration. - - Returns: - A context manager that yields the configured TemporalTraceProvider. - """ previous_runner = get_default_agent_runner() previous_trace_provider = get_trace_provider() provider = TemporalTraceProvider( @@ -111,10 +88,6 @@ def _data_converter(converter: DataConverter | None) -> DataConverter: class OpenAIAgentsPlugin(SimplePlugin): """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 @@ -127,16 +100,6 @@ class OpenAIAgentsPlugin(SimplePlugin): 4. Automatically registers MCP server activities and manages their lifecycles 5. Manages the OpenAI agent runtime overrides during worker execution - Args: - model_params: Configuration parameters for Temporal activity execution - of model calls. If None, default parameters will be used. - model_provider: Optional model provider for custom model implementations. - Useful for testing or custom model integrations. - mcp_server_providers: Sequence of MCP servers to automatically register with the worker. - The plugin will wrap each server in a TemporalMCPServer if needed and - manage their connection lifecycles tied to the worker lifetime. This is - the recommended way to use MCP servers with Temporal workflows. - Example: >>> from temporalio.client import Client >>> from temporalio.worker import Worker @@ -201,6 +164,9 @@ def __init__( but should not be disabled on all workers, or agents will not be able to progress. add_temporal_spans: Whether to add temporal spans to traces use_otel_instrumentation: If set to true, enable open telemetry instrumentation. + Warning: use_otel_instrumentation is experimental and behavior may change in future versions. + Use with caution in production environments. + """ if model_params is None: model_params = ModelActivityParameters() @@ -280,7 +246,7 @@ def workflow_runner(runner: WorkflowRunner | None) -> WorkflowRunner: @asynccontextmanager async def run_context() -> AsyncIterator[None]: with self.tracing_context(): - with set_open_ai_agent_temporal_overrides( + with _set_open_ai_agent_temporal_overrides( model_params, start_spans_in_replay=use_otel_instrumentation ): yield diff --git a/temporalio/contrib/openai_agents/_trace_interceptor.py b/temporalio/contrib/openai_agents/_trace_interceptor.py index c000314da..66297e20b 100644 --- a/temporalio/contrib/openai_agents/_trace_interceptor.py +++ b/temporalio/contrib/openai_agents/_trace_interceptor.py @@ -65,10 +65,6 @@ class OpenAIAgentsContextPropagationInterceptor( ): """Interceptor that propagates OpenAI agent tracing context through Temporal workflows and activities. - .. warning:: - This API is experimental and may change in future versions. - Use with caution in production environments. - This interceptor enables tracing of OpenAI agent operations across Temporal workflows and activities. It propagates trace context through workflow and activity boundaries, allowing for end-to-end tracing of agent operations. diff --git a/temporalio/contrib/openai_agents/testing.py b/temporalio/contrib/openai_agents/testing.py index 45a7a1465..d4641105c 100644 --- a/temporalio/contrib/openai_agents/testing.py +++ b/temporalio/contrib/openai_agents/testing.py @@ -39,19 +39,11 @@ class ResponseBuilders: - """Builders for creating model responses for testing. - - .. warning:: - This API is experimental and may change in the future. - """ + """Builders for creating model responses for testing.""" @staticmethod def model_response(output: TResponseOutputItem) -> ModelResponse: - """Create a ModelResponse with the given output. - - .. warning:: - This API is experimental and may change in the future. - """ + """Create a ModelResponse with the given output.""" return ModelResponse( output=[output], usage=Usage(), @@ -60,11 +52,7 @@ def model_response(output: TResponseOutputItem) -> ModelResponse: @staticmethod def response_output_message(text: str) -> ResponseOutputMessage: - """Create a ResponseOutputMessage with text content. - - .. warning:: - This API is experimental and may change in the future. - """ + """Create a ResponseOutputMessage with text content.""" return ResponseOutputMessage( id="", content=[ @@ -81,11 +69,7 @@ def response_output_message(text: str) -> ResponseOutputMessage: @staticmethod def tool_call(arguments: str, name: str) -> ModelResponse: - """Create a ModelResponse with a function tool call. - - .. warning:: - This API is experimental and may change in the future. - """ + """Create a ModelResponse with a function tool call.""" return ResponseBuilders.model_response( ResponseFunctionToolCall( arguments=arguments, @@ -99,57 +83,33 @@ def tool_call(arguments: str, name: str) -> ModelResponse: @staticmethod def output_message(text: str) -> ModelResponse: - """Create a ModelResponse with an output message. - - .. warning:: - This API is experimental and may change in the future. - """ + """Create a ModelResponse with an output message.""" return ResponseBuilders.model_response( ResponseBuilders.response_output_message(text) ) class TestModelProvider(ModelProvider): - """Test model provider which simply returns the given module. - - .. warning:: - This API is experimental and may change in the future. - """ + """Test model provider which simply returns the given module.""" __test__ = False def __init__(self, model: Model): - """Initialize a test model provider with a model. - - .. warning:: - This API is experimental and may change in the future. - """ + """Initialize a test model provider with a model.""" self._model = model def get_model(self, model_name: str | None) -> Model: - """Get a model from the model provider. - - .. warning:: - This API is experimental and may change in the future. - """ + """Get a model from the model provider.""" return self._model class TestModel(Model): - """Test model for use mocking model responses. - - .. warning:: - This API is experimental and may change in the future. - """ + """Test model for use mocking model responses.""" __test__ = False def __init__(self, fn: Callable[[], ModelResponse]) -> None: - """Initialize a test model with a callable. - - .. warning:: - This API is experimental and may change in the future. - """ + """Initialize a test model with a callable.""" self.fn = fn async def get_response( @@ -182,11 +142,7 @@ def stream_response( @staticmethod def returning_responses(responses: list[ModelResponse]) -> "TestModel": - """Create a mock model which sequentially returns responses from a list. - - .. warning:: - This API is experimental and may change in the future. - """ + """Create a mock model which sequentially returns responses from a list.""" i = iter(responses) return TestModel(lambda: next(i)) @@ -197,9 +153,6 @@ class AgentEnvironment: This async context manager provides a convenient way to set up testing environments for OpenAI agents with mocked model calls and Temporal integration. - .. warning:: - This API is experimental and may change in the future. - Example: >>> from temporalio.contrib.openai_agents.testing import AgentEnvironment, TestModelProvider, ResponseBuilders >>> from temporalio.client import Client @@ -246,9 +199,8 @@ def __init__( register_activities: Whether to register activities during worker execution. add_temporal_spans: Whether to add temporal spans to traces use_otel_instrumentation: If set to true, enable open telemetry instrumentation. - - .. warning:: - This API is experimental and may change in the future. + Warning: use_otel_instrumentation is experimental and behavior may change in future versions. + Use with caution in production environments. """ self._model_params = model_params self._model_provider = None @@ -289,9 +241,6 @@ def applied_on_client(self, client: Client) -> Client: Returns: A new Client instance with the OpenAI agents plugin applied. - - .. warning:: - This API is experimental and may change in the future. """ if self._plugin is None: raise RuntimeError( @@ -305,11 +254,7 @@ def applied_on_client(self, client: Client) -> Client: @property def openai_agents_plugin(self) -> OpenAIAgentsPlugin: - """Get the underlying OpenAI agents plugin. - - .. warning:: - This API is experimental and may change in the future. - """ + """Get the underlying OpenAI agents plugin.""" if self._plugin is None: raise RuntimeError( "AgentEnvironment must be entered before accessing plugin" diff --git a/temporalio/contrib/openai_agents/workflow.py b/temporalio/contrib/openai_agents/workflow.py index 772bf4555..cf9ddbc70 100644 --- a/temporalio/contrib/openai_agents/workflow.py +++ b/temporalio/contrib/openai_agents/workflow.py @@ -51,10 +51,6 @@ def activity_as_tool( ) -> Tool: """Convert a single Temporal activity function to an OpenAI agent tool. - .. warning:: - This API is experimental and may change in future versions. - Use with caution in production environments. - This function takes a Temporal activity function and converts it into an OpenAI agent tool that can be used by the agent to execute the activity during workflow execution. The tool will automatically handle the conversion @@ -171,10 +167,6 @@ def nexus_operation_as_tool( ) -> Tool: """Convert a Nexus operation into an OpenAI agent tool. - .. warning:: - This API is experimental and may change in future versions. - Use with caution in production environments. - This function takes a Nexus operation and converts it into an OpenAI agent tool that can be used by the agent to execute the operation during workflow execution. The tool will automatically handle the conversion @@ -257,10 +249,6 @@ def stateless_mcp_server( ) -> "MCPServer": """A stateless MCP server implementation for Temporal workflows. - .. warning:: - This API is experimental and may change in future versions. - Use with caution in production environments. - This uses a TemporalMCPServer of the same name registered with the OpenAIAgents plugin to implement durable MCP operations statelessly. @@ -292,10 +280,6 @@ def stateful_mcp_server( ) -> AbstractAsyncContextManager["MCPServer"]: """A stateful MCP server implementation for Temporal workflows. - .. warning:: - This API is experimental and may change in future versions. - Use with caution in production environments. - This wraps an MCP server to maintain a persistent connection throughout the workflow execution. It creates a dedicated worker that stays connected to the MCP server and processes operations on a dedicated task queue. @@ -327,10 +311,6 @@ def stateful_mcp_server( class ToolSerializationError(TemporalError): """Error that occurs when a tool output could not be serialized. - .. warning:: - This exception is experimental and may change in future versions. - Use with caution in production environments. - This exception is raised when a tool (created from an activity or Nexus operation) returns a value that cannot be properly serialized for use by the OpenAI agent. All tool outputs must be convertible to strings for the agent to process them. @@ -351,9 +331,4 @@ class ToolSerializationError(TemporalError): class AgentsWorkflowError(TemporalError): - """Error that occurs when the agents SDK raises an error which should terminate the calling workflow or update. - - .. warning:: - This exception is experimental and may change in future versions. - Use with caution in production environments. - """ + """Error that occurs when the agents SDK raises an error which should terminate the calling workflow or update."""