diff --git a/temporalio/contrib/openai_agents/workflow.py b/temporalio/contrib/openai_agents/workflow.py index 63ec43154..51eff86a3 100644 --- a/temporalio/contrib/openai_agents/workflow.py +++ b/temporalio/contrib/openai_agents/workflow.py @@ -46,6 +46,7 @@ def activity_as_tool( versioning_intent: Optional[VersioningIntent] = None, summary: Optional[str] = None, priority: Priority = Priority.default, + strict_json_schema: bool = True, ) -> Tool: """Convert a single Temporal activity function to an OpenAI agent tool. @@ -61,6 +62,8 @@ def activity_as_tool( Args: fn: A Temporal activity function to convert to a tool. + strict_json_schema: Whether the tool should follow a strict schema. + See https://openai.github.io/openai-agents-python/ref/tool/#agents.tool.FunctionTool.strict_json_schema For other arguments, refer to :py:mod:`workflow` :py:meth:`start_activity` Returns: @@ -151,7 +154,7 @@ async def run_activity(ctx: RunContextWrapper[Any], input: str) -> Any: description=schema.description or "", params_json_schema=schema.params_json_schema, on_invoke_tool=run_activity, - strict_json_schema=True, + strict_json_schema=strict_json_schema, ) @@ -161,6 +164,7 @@ def nexus_operation_as_tool( service: Type[Any], endpoint: str, schedule_to_close_timeout: Optional[timedelta] = None, + strict_json_schema: bool = True, ) -> Tool: """Convert a Nexus operation into an OpenAI agent tool. @@ -177,6 +181,7 @@ def nexus_operation_as_tool( fn: A Nexus operation to convert into a tool. service: The Nexus service class that contains the operation. endpoint: The Nexus endpoint to use for the operation. + strict_json_schema: Whether the tool should follow a strict schema Returns: An OpenAI agent tool that wraps the provided operation. @@ -237,7 +242,7 @@ async def run_operation(ctx: RunContextWrapper[Any], input: str) -> Any: description=schema.description or "", params_json_schema=schema.params_json_schema, on_invoke_tool=run_operation, - strict_json_schema=True, + strict_json_schema=strict_json_schema, )