From 8e43320c6dbde992c7c3c25d1c271214195c20a7 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Tue, 8 Jul 2025 10:58:24 -0700 Subject: [PATCH 1/5] Stage changes for next update to openai integration --- openai_agents/run_agents_as_tools_workflow.py | 7 +-- openai_agents/run_customer_service_client.py | 6 +-- openai_agents/run_hello_world_workflow.py | 9 ++-- openai_agents/run_research_workflow.py | 6 +-- openai_agents/run_tools_workflow.py | 6 +-- openai_agents/run_worker.py | 17 +++----- openai_agents/workflows/tools_workflow.py | 11 ++--- pyproject.toml | 2 +- uv.lock | 43 +++++++++++++------ 9 files changed, 52 insertions(+), 55 deletions(-) diff --git a/openai_agents/run_agents_as_tools_workflow.py b/openai_agents/run_agents_as_tools_workflow.py index 7bd61cb5..b8c25464 100644 --- a/openai_agents/run_agents_as_tools_workflow.py +++ b/openai_agents/run_agents_as_tools_workflow.py @@ -1,10 +1,7 @@ import asyncio from temporalio.client import Client -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) - +from temporalio.contrib.pydantic import pydantic_data_converter from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow @@ -12,7 +9,7 @@ async def main(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) # Execute a workflow diff --git a/openai_agents/run_customer_service_client.py b/openai_agents/run_customer_service_client.py index c4277dc4..f129d0d4 100644 --- a/openai_agents/run_customer_service_client.py +++ b/openai_agents/run_customer_service_client.py @@ -7,9 +7,7 @@ WorkflowUpdateFailedError, ) from temporalio.common import QueryRejectCondition -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) +from temporalio.contrib.pydantic import pydantic_data_converter from temporalio.service import RPCError, RPCStatusCode from openai_agents.workflows.customer_service_workflow import ( @@ -26,7 +24,7 @@ async def main(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) handle = client.get_workflow_handle(args.conversation_id) diff --git a/openai_agents/run_hello_world_workflow.py b/openai_agents/run_hello_world_workflow.py index a7baea57..16fd9d5f 100644 --- a/openai_agents/run_hello_world_workflow.py +++ b/openai_agents/run_hello_world_workflow.py @@ -1,18 +1,17 @@ import asyncio from temporalio.client import Client -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) -from openai_agents.workflows.hello_world_workflow import HelloWorldAgent +from openai_agents.workflows.research_bot_workflow import ResearchWorkflow +from temporalio.contrib.pydantic import pydantic_data_converter +from openai_agents.workflows.hello_world_workflow import HelloWorldAgent async def main(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) # Execute a workflow diff --git a/openai_agents/run_research_workflow.py b/openai_agents/run_research_workflow.py index 72836e2c..f72d5366 100644 --- a/openai_agents/run_research_workflow.py +++ b/openai_agents/run_research_workflow.py @@ -1,18 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) from openai_agents.workflows.research_bot_workflow import ResearchWorkflow +from temporalio.contrib.pydantic import pydantic_data_converter async def main(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) # Execute a workflow diff --git a/openai_agents/run_tools_workflow.py b/openai_agents/run_tools_workflow.py index a6683fb7..51f3b823 100644 --- a/openai_agents/run_tools_workflow.py +++ b/openai_agents/run_tools_workflow.py @@ -1,18 +1,16 @@ import asyncio from temporalio.client import Client -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) from openai_agents.workflows.tools_workflow import ToolsWorkflow +from temporalio.contrib.pydantic import pydantic_data_converter async def main(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) # Execute a workflow diff --git a/openai_agents/run_worker.py b/openai_agents/run_worker.py index acee5406..7c2751bf 100644 --- a/openai_agents/run_worker.py +++ b/openai_agents/run_worker.py @@ -6,14 +6,12 @@ from temporalio import workflow from temporalio.client import Client -from temporalio.contrib.openai_agents.invoke_model_activity import ModelActivity -from temporalio.contrib.openai_agents.open_ai_data_converter import ( - open_ai_data_converter, -) -from temporalio.contrib.openai_agents.temporal_openai_agents import ( +from temporalio.contrib.openai_agents import ( set_open_ai_agent_temporal_overrides, + ModelActivity, ) from temporalio.worker import Worker +from temporalio.contrib.pydantic import pydantic_data_converter from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow from openai_agents.workflows.customer_service_workflow import CustomerServiceWorkflow @@ -24,16 +22,13 @@ async def main(): - with set_open_ai_agent_temporal_overrides( - start_to_close_timeout=timedelta(seconds=60), - ): + with set_open_ai_agent_temporal_overrides(): # Create client connected to server at the given address client = await Client.connect( "localhost:7233", - data_converter=open_ai_data_converter, + data_converter=pydantic_data_converter, ) - model_activity = ModelActivity(model_provider=None) worker = Worker( client, task_queue="openai-agents-task-queue", @@ -45,7 +40,7 @@ async def main(): AgentsAsToolsWorkflow, ], activities=[ - model_activity.invoke_model_activity, + ModelActivity().invoke_model_activity, get_weather, ], ) diff --git a/openai_agents/workflows/tools_workflow.py b/openai_agents/workflows/tools_workflow.py index 0b981f59..e34c4bcf 100644 --- a/openai_agents/workflows/tools_workflow.py +++ b/openai_agents/workflows/tools_workflow.py @@ -3,13 +3,10 @@ from datetime import timedelta from temporalio import workflow -from temporalio.contrib.openai_agents.temporal_tools import activity_as_tool +from temporalio.contrib import openai_agents as temporal_agents +from agents import Agent, Runner -# Import our activity, passing it through the sandbox -with workflow.unsafe.imports_passed_through(): - from agents import Agent, Runner - - from openai_agents.workflows.get_weather_activity import get_weather +from openai_agents.workflows.get_weather_activity import get_weather @workflow.defn @@ -20,7 +17,7 @@ async def run(self, question: str) -> str: name="Hello world", instructions="You are a helpful agent.", tools=[ - activity_as_tool( + temporal_agents.workflow.activity_as_tool( get_weather, start_to_close_timeout=timedelta(seconds=10) ) ], diff --git a/pyproject.toml b/pyproject.toml index b82bd912..93d456ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ open-telemetry = [ ] openai-agents = [ "openai-agents >= 0.0.19", - "temporalio[openai-agents] >= 1.13.0", + "temporalio[openai-agents]@git+https://github.com/temporalio/sdk-python@main", ] pydantic-converter = ["pydantic>=2.10.6,<3"] sentry = ["sentry-sdk>=1.11.0,<2"] diff --git a/uv.lock b/uv.lock index 21e6c17e..640d8743 100644 --- a/uv.lock +++ b/uv.lock @@ -502,6 +502,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, ] +[[package]] +name = "eval-type-backport" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/30/ea/8b0ac4469d4c347c6a385ff09dc3c048c2d021696664e26c7ee6791631b5/eval_type_backport-0.2.2.tar.gz", hash = "sha256:f0576b4cf01ebb5bd358d02314d31846af5e07678387486e2c798af0e7d849c1", size = 9079, upload-time = "2024-12-21T20:09:46.005Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ce/31/55cd413eaccd39125368be33c46de24a1f639f2e12349b0361b4678f3915/eval_type_backport-0.2.2-py3-none-any.whl", hash = "sha256:cb6ad7c393517f476f96d456d0412ea80f0a8cf96f6892834cd9340149111b0a", size = 5830, upload-time = "2024-12-21T20:09:44.175Z" }, +] + [[package]] name = "exceptiongroup" version = "1.3.0" @@ -1386,6 +1395,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, ] +[[package]] +name = "nexus-rpc" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ef/66/540687556bd28cf1ec370cc6881456203dfddb9dab047b8979c6865b5984/nexus_rpc-1.1.0.tar.gz", hash = "sha256:d65ad6a2f54f14e53ebe39ee30555eaeb894102437125733fb13034a04a44553", size = 77383, upload-time = "2025-07-07T19:03:58.368Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bf/2f/9e9d0dcaa4c6ffa22b7aa31069a8a264c753ff8027b36af602cce038c92f/nexus_rpc-1.1.0-py3-none-any.whl", hash = "sha256:d1b007af2aba186a27e736f8eaae39c03aed05b488084ff6c3d1785c9ba2ad38", size = 27743, upload-time = "2025-07-07T19:03:57.556Z" }, +] + [[package]] name = "numpy" version = "1.26.4" @@ -1450,7 +1471,7 @@ wheels = [ [[package]] name = "openai-agents" -version = "0.0.19" +version = "0.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "griffe" }, @@ -1462,9 +1483,9 @@ dependencies = [ { name = "types-requests", version = "2.32.4.20250611", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/53/a3/301c6302bd2142c44674b4ccfb90d3da6771e17cef2e9fa2744256fd8dca/openai_agents-0.0.19.tar.gz", hash = "sha256:4090d683ef7257b3f6299f76e477ad51a970fd76de7c55df65f4bc5029580f2b", size = 1369353, upload-time = "2025-06-18T00:49:15.665Z" } +sdist = { url = "https://files.pythonhosted.org/packages/99/f8/a292d8f506997355755d88db619966539ec838ce18f070c5a101e5a430ec/openai_agents-0.1.0.tar.gz", hash = "sha256:a697a4fdd881a7a16db8c0dcafba0f17d9e90b6236a4b79923bd043b6ae86d80", size = 1379588, upload-time = "2025-06-27T20:58:03.186Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/20/69/899b33c97d5ee6ce454d5cdf89ddddcec9100bece4ed508229b06b1a07ca/openai_agents-0.0.19-py3-none-any.whl", hash = "sha256:daff03408e3a069e2a04fdf3968296cdc5f63ab635df1d8a54ca2e9352e68516", size = 126694, upload-time = "2025-06-18T00:49:13.906Z" }, + { url = "https://files.pythonhosted.org/packages/31/5b/326e6b1b661dbef718977a8379f9702a4eec1df772450517870beeb3af35/openai_agents-0.1.0-py3-none-any.whl", hash = "sha256:6a8ef71d3f20aecba0f01bca2e059590d1c23f5adc02d780cb5921ea8a7ca774", size = 130620, upload-time = "2025-06-27T20:58:01.461Z" }, ] [[package]] @@ -2437,25 +2458,19 @@ wheels = [ [[package]] name = "temporalio" -version = "1.13.0" -source = { registry = "https://pypi.org/simple" } +version = "1.14.0" +source = { git = "https://github.com/temporalio/sdk-python?rev=main#61af3ea095e198378c158516a45e156b0a4d64ec" } dependencies = [ + { name = "nexus-rpc" }, { name = "protobuf" }, { name = "python-dateutil", marker = "python_full_version < '3.11'" }, { name = "types-protobuf" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/3e/a3/a76477b523937f47a21941188c16b3c6b1eef6baadc7c8efeea497d909de/temporalio-1.13.0.tar.gz", hash = "sha256:5a979eee5433da6ab5d8a2bcde25a1e7d454e91920acb0bf7ca93d415750828b", size = 1558745, upload-time = "2025-06-20T19:57:26.944Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/f5/f4/a5a74284c671bd50ce7353ad1dad7dab1a795f891458454049e95bc5378f/temporalio-1.13.0-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:7ee14cab581352e77171d1e4ce01a899231abfe75c5f7233e3e260f361a344cc", size = 12086961, upload-time = "2025-06-20T19:57:15.25Z" }, - { url = "https://files.pythonhosted.org/packages/1f/b7/5dc6e34f4e9a3da8b75cb3fe0d32edca1d9201d598c38d022501d38650a9/temporalio-1.13.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:575a0c57dbb089298b4775f3aca86ebaf8d58d5ba155e7fc5509877c25e6bb44", size = 11745239, upload-time = "2025-06-20T19:57:17.934Z" }, - { url = "https://files.pythonhosted.org/packages/04/30/4b9b15af87c181fd9364b61971faa0faa07d199320d7ff1712b5d51b5bbb/temporalio-1.13.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6bf099a27f22c0dbc22f3d86dba76d59be5da812ff044ba3fa183e3e14bd5e9a", size = 12119197, upload-time = "2025-06-20T19:57:20.509Z" }, - { url = "https://files.pythonhosted.org/packages/46/9f/a5b627d773974c654b6cd22ed3937e7e2471023af244ea417f0e917e617b/temporalio-1.13.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f7e20c711f41c66877b9d54ab33c79a14ccaac9ed498a174274f6129110f4d84", size = 12413459, upload-time = "2025-06-20T19:57:22.816Z" }, - { url = "https://files.pythonhosted.org/packages/a3/73/efb6957212eb8c8dfff26c7c2c6ddf745aa5990a3b722cff17c8feaa66fc/temporalio-1.13.0-cp39-abi3-win_amd64.whl", hash = "sha256:9286cb84c1e078b2bcc6e8c6bd0be878d8ed395be991ac0d7cff555e3a82ac0b", size = 12440644, upload-time = "2025-06-20T19:57:25.175Z" }, -] [package.optional-dependencies] openai-agents = [ + { name = "eval-type-backport", marker = "python_full_version < '3.10'" }, { name = "openai-agents" }, ] opentelemetry = [ @@ -2575,7 +2590,7 @@ open-telemetry = [ ] openai-agents = [ { name = "openai-agents", specifier = ">=0.0.19" }, - { name = "temporalio", extras = ["openai-agents"], specifier = ">=1.13.0" }, + { name = "temporalio", extras = ["openai-agents"], git = "https://github.com/temporalio/sdk-python?rev=main" }, ] pydantic-converter = [{ name = "pydantic", specifier = ">=2.10.6,<3" }] sentry = [{ name = "sentry-sdk", specifier = ">=1.11.0,<2" }] From 43a70360c0a03e6c5541d219e7d693808aaf826b Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Fri, 11 Jul 2025 12:14:58 -0700 Subject: [PATCH 2/5] Update temporalio to latest --- pyproject.toml | 4 ++-- uv.lock | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 93d456ef..166038a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }] requires-python = "~=3.9" readme = "README.md" license = "MIT" -dependencies = ["temporalio>=1.13.0,<2"] +dependencies = ["temporalio>=1.14.1,<2"] [project.urls] Homepage = "https://github.com/temporalio/samples-python" @@ -50,7 +50,7 @@ open-telemetry = [ ] openai-agents = [ "openai-agents >= 0.0.19", - "temporalio[openai-agents]@git+https://github.com/temporalio/sdk-python@main", + "temporalio[openai-agents] >= 1.14.1", ] pydantic-converter = ["pydantic>=2.10.6,<3"] sentry = ["sentry-sdk>=1.11.0,<2"] diff --git a/uv.lock b/uv.lock index 640d8743..c5546c89 100644 --- a/uv.lock +++ b/uv.lock @@ -2458,8 +2458,8 @@ wheels = [ [[package]] name = "temporalio" -version = "1.14.0" -source = { git = "https://github.com/temporalio/sdk-python?rev=main#61af3ea095e198378c158516a45e156b0a4d64ec" } +version = "1.14.1" +source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nexus-rpc" }, { name = "protobuf" }, @@ -2467,6 +2467,14 @@ dependencies = [ { name = "types-protobuf" }, { name = "typing-extensions" }, ] +sdist = { url = "https://files.pythonhosted.org/packages/40/23/ef5ed581d26112e21c4a6d4ddc2c4eaa5700c0d70b53b07566553e9b7d90/temporalio-1.14.1.tar.gz", hash = "sha256:b240cf56f64add65beb75bd18aa854ac35bdc2505097af5af1e235d611190a9d", size = 1607639, upload-time = "2025-07-10T20:56:43.485Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/66/6dc4f5a647a9901cf19e012c442173574babdc879ccaf4cb166662a23ef0/temporalio-1.14.1-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:ebde00b59af72e512e5837445e4b5b8aa445431d57a71bbeb57a5ba8a93ac8be", size = 12508009, upload-time = "2025-07-10T20:56:30.653Z" }, + { url = "https://files.pythonhosted.org/packages/bb/dc/654ebcc92c658180576127ac6dc047fab43b7730f39df4439645e91577fb/temporalio-1.14.1-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:3c21cff8fdc60fbcc9acd91e6c119b0b5f9de7671fe806459f00d68bd4ecae78", size = 12091653, upload-time = "2025-07-10T20:56:33.199Z" }, + { url = "https://files.pythonhosted.org/packages/8a/58/7fc3a7bde275c059e42d0279c54e8e66642b67be8eda21b31347f4277186/temporalio-1.14.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9f984b503ae741213fe71128d6193076f3267691561ff3c55dbe798f92e6ee1b", size = 12451995, upload-time = "2025-07-10T20:56:36.055Z" }, + { url = "https://files.pythonhosted.org/packages/98/12/14f6a7a1f4aebb7d846469f5c1cd165cce55b793ded6ce5fc315bd83e28f/temporalio-1.14.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:830cb1a820624a5e64f6c874b5aca6ad9eb841295407dd2011074159a2d28bdb", size = 12688904, upload-time = "2025-07-10T20:56:38.501Z" }, + { url = "https://files.pythonhosted.org/packages/b4/ed/c09f1ca41d5ed9f9a777a0ddd5bc225f8300bab8b42bc6751195566706fb/temporalio-1.14.1-cp39-abi3-win_amd64.whl", hash = "sha256:ad4e6a16b42bb34aebec62fb8bbe8f64643d8268ed6d7db337dfe98a76799bb0", size = 12758696, upload-time = "2025-07-10T20:56:41.266Z" }, +] [package.optional-dependencies] openai-agents = [ @@ -2546,7 +2554,7 @@ trio-async = [ ] [package.metadata] -requires-dist = [{ name = "temporalio", specifier = ">=1.13.0,<2" }] +requires-dist = [{ name = "temporalio", specifier = ">=1.14.1,<2" }] [package.metadata.requires-dev] bedrock = [{ name = "boto3", specifier = ">=1.34.92,<2" }] @@ -2590,7 +2598,7 @@ open-telemetry = [ ] openai-agents = [ { name = "openai-agents", specifier = ">=0.0.19" }, - { name = "temporalio", extras = ["openai-agents"], git = "https://github.com/temporalio/sdk-python?rev=main" }, + { name = "temporalio", extras = ["openai-agents"], specifier = ">=1.14.1" }, ] pydantic-converter = [{ name = "pydantic", specifier = ">=2.10.6,<3" }] sentry = [{ name = "sentry-sdk", specifier = ">=1.11.0,<2" }] From 03ffce04865c5104c204b6e0aa9b7ad8f216bb9b Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Fri, 11 Jul 2025 12:25:48 -0700 Subject: [PATCH 3/5] Formatting --- openai_agents/run_hello_world_workflow.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openai_agents/run_hello_world_workflow.py b/openai_agents/run_hello_world_workflow.py index 16fd9d5f..16dda392 100644 --- a/openai_agents/run_hello_world_workflow.py +++ b/openai_agents/run_hello_world_workflow.py @@ -7,6 +7,7 @@ from openai_agents.workflows.hello_world_workflow import HelloWorldAgent + async def main(): # Create client connected to server at the given address client = await Client.connect( From 33d4389850b5eb8cb80dc3ac4b7c07ac93188e33 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Fri, 11 Jul 2025 12:56:58 -0700 Subject: [PATCH 4/5] remove passthrough --- .../workflows/agents_as_tools_workflow.py | 3 +- .../workflows/customer_service_workflow.py | 35 +++++++++---------- .../workflows/hello_world_workflow.py | 4 +-- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/openai_agents/workflows/agents_as_tools_workflow.py b/openai_agents/workflows/agents_as_tools_workflow.py index 76a68ea4..4eb3d21c 100644 --- a/openai_agents/workflows/agents_as_tools_workflow.py +++ b/openai_agents/workflows/agents_as_tools_workflow.py @@ -1,7 +1,6 @@ from temporalio import workflow -with workflow.unsafe.imports_passed_through(): - from agents import Agent, ItemHelpers, MessageOutputItem, RunConfig, Runner, trace +from agents import Agent, ItemHelpers, MessageOutputItem, RunConfig, Runner, trace """ This example shows the agents-as-tools pattern. The frontline agent receives a user message and diff --git a/openai_agents/workflows/customer_service_workflow.py b/openai_agents/workflows/customer_service_workflow.py index 9a8d38fc..041bae00 100644 --- a/openai_agents/workflows/customer_service_workflow.py +++ b/openai_agents/workflows/customer_service_workflow.py @@ -2,25 +2,24 @@ from temporalio import workflow -with workflow.unsafe.imports_passed_through(): - from agents import ( - Agent, - HandoffOutputItem, - ItemHelpers, - MessageOutputItem, - RunConfig, - Runner, - ToolCallItem, - ToolCallOutputItem, - TResponseInputItem, - trace, - ) +from agents import ( + Agent, + HandoffOutputItem, + ItemHelpers, + MessageOutputItem, + RunConfig, + Runner, + ToolCallItem, + ToolCallOutputItem, + TResponseInputItem, + trace, +) - from openai_agents.workflows.customer_service import ( - AirlineAgentContext, - ProcessUserMessageInput, - init_agents, - ) +from openai_agents.workflows.customer_service import ( + AirlineAgentContext, + ProcessUserMessageInput, + init_agents, +) @workflow.defn diff --git a/openai_agents/workflows/hello_world_workflow.py b/openai_agents/workflows/hello_world_workflow.py index aff1478e..96961c35 100644 --- a/openai_agents/workflows/hello_world_workflow.py +++ b/openai_agents/workflows/hello_world_workflow.py @@ -1,8 +1,6 @@ from temporalio import workflow -# Import agent Agent and Runner -with workflow.unsafe.imports_passed_through(): - from agents import Agent, Runner +from agents import Agent, Runner @workflow.defn From e5d6901547bea9d1ff979915ba3e05b7d38d6b7e Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Fri, 11 Jul 2025 12:58:05 -0700 Subject: [PATCH 5/5] Run isort --- openai_agents/run_agents_as_tools_workflow.py | 1 + openai_agents/run_hello_world_workflow.py | 3 +-- openai_agents/run_research_workflow.py | 2 +- openai_agents/run_tools_workflow.py | 2 +- openai_agents/run_worker.py | 4 ++-- openai_agents/workflows/agents_as_tools_workflow.py | 3 +-- openai_agents/workflows/customer_service_workflow.py | 3 +-- openai_agents/workflows/hello_world_workflow.py | 3 +-- openai_agents/workflows/tools_workflow.py | 2 +- 9 files changed, 10 insertions(+), 13 deletions(-) diff --git a/openai_agents/run_agents_as_tools_workflow.py b/openai_agents/run_agents_as_tools_workflow.py index b8c25464..9c37beb0 100644 --- a/openai_agents/run_agents_as_tools_workflow.py +++ b/openai_agents/run_agents_as_tools_workflow.py @@ -2,6 +2,7 @@ from temporalio.client import Client from temporalio.contrib.pydantic import pydantic_data_converter + from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow diff --git a/openai_agents/run_hello_world_workflow.py b/openai_agents/run_hello_world_workflow.py index 16dda392..ee5dee90 100644 --- a/openai_agents/run_hello_world_workflow.py +++ b/openai_agents/run_hello_world_workflow.py @@ -1,11 +1,10 @@ import asyncio from temporalio.client import Client - -from openai_agents.workflows.research_bot_workflow import ResearchWorkflow from temporalio.contrib.pydantic import pydantic_data_converter from openai_agents.workflows.hello_world_workflow import HelloWorldAgent +from openai_agents.workflows.research_bot_workflow import ResearchWorkflow async def main(): diff --git a/openai_agents/run_research_workflow.py b/openai_agents/run_research_workflow.py index f72d5366..136874db 100644 --- a/openai_agents/run_research_workflow.py +++ b/openai_agents/run_research_workflow.py @@ -1,9 +1,9 @@ import asyncio from temporalio.client import Client +from temporalio.contrib.pydantic import pydantic_data_converter from openai_agents.workflows.research_bot_workflow import ResearchWorkflow -from temporalio.contrib.pydantic import pydantic_data_converter async def main(): diff --git a/openai_agents/run_tools_workflow.py b/openai_agents/run_tools_workflow.py index 51f3b823..2635be6f 100644 --- a/openai_agents/run_tools_workflow.py +++ b/openai_agents/run_tools_workflow.py @@ -1,9 +1,9 @@ import asyncio from temporalio.client import Client +from temporalio.contrib.pydantic import pydantic_data_converter from openai_agents.workflows.tools_workflow import ToolsWorkflow -from temporalio.contrib.pydantic import pydantic_data_converter async def main(): diff --git a/openai_agents/run_worker.py b/openai_agents/run_worker.py index 6d9cc77d..de2693f4 100644 --- a/openai_agents/run_worker.py +++ b/openai_agents/run_worker.py @@ -5,12 +5,12 @@ from temporalio.client import Client from temporalio.contrib.openai_agents import ( - set_open_ai_agent_temporal_overrides, ModelActivity, ModelActivityParameters, + set_open_ai_agent_temporal_overrides, ) -from temporalio.worker import Worker from temporalio.contrib.pydantic import pydantic_data_converter +from temporalio.worker import Worker from openai_agents.workflows.agents_as_tools_workflow import AgentsAsToolsWorkflow from openai_agents.workflows.customer_service_workflow import CustomerServiceWorkflow diff --git a/openai_agents/workflows/agents_as_tools_workflow.py b/openai_agents/workflows/agents_as_tools_workflow.py index 4eb3d21c..db849c1c 100644 --- a/openai_agents/workflows/agents_as_tools_workflow.py +++ b/openai_agents/workflows/agents_as_tools_workflow.py @@ -1,6 +1,5 @@ -from temporalio import workflow - from agents import Agent, ItemHelpers, MessageOutputItem, RunConfig, Runner, trace +from temporalio import workflow """ This example shows the agents-as-tools pattern. The frontline agent receives a user message and diff --git a/openai_agents/workflows/customer_service_workflow.py b/openai_agents/workflows/customer_service_workflow.py index 041bae00..3186c5ab 100644 --- a/openai_agents/workflows/customer_service_workflow.py +++ b/openai_agents/workflows/customer_service_workflow.py @@ -1,7 +1,5 @@ from __future__ import annotations as _annotations -from temporalio import workflow - from agents import ( Agent, HandoffOutputItem, @@ -14,6 +12,7 @@ TResponseInputItem, trace, ) +from temporalio import workflow from openai_agents.workflows.customer_service import ( AirlineAgentContext, diff --git a/openai_agents/workflows/hello_world_workflow.py b/openai_agents/workflows/hello_world_workflow.py index 96961c35..dd6b2e41 100644 --- a/openai_agents/workflows/hello_world_workflow.py +++ b/openai_agents/workflows/hello_world_workflow.py @@ -1,6 +1,5 @@ -from temporalio import workflow - from agents import Agent, Runner +from temporalio import workflow @workflow.defn diff --git a/openai_agents/workflows/tools_workflow.py b/openai_agents/workflows/tools_workflow.py index e34c4bcf..c9f80e9f 100644 --- a/openai_agents/workflows/tools_workflow.py +++ b/openai_agents/workflows/tools_workflow.py @@ -2,9 +2,9 @@ from datetime import timedelta +from agents import Agent, Runner from temporalio import workflow from temporalio.contrib import openai_agents as temporal_agents -from agents import Agent, Runner from openai_agents.workflows.get_weather_activity import get_weather