From 5962fb9e3752434913269d7306032bf4ba5ecbea Mon Sep 17 00:00:00 2001 From: Jatong Su Date: Thu, 11 Sep 2025 13:25:56 -0400 Subject: [PATCH 1/3] accept workflows list --- .../lib/core/temporal/workers/worker.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/agentex/lib/core/temporal/workers/worker.py b/src/agentex/lib/core/temporal/workers/worker.py index 464b44a4..25fdf974 100644 --- a/src/agentex/lib/core/temporal/workers/worker.py +++ b/src/agentex/lib/core/temporal/workers/worker.py @@ -4,7 +4,7 @@ import uuid from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor -from typing import Any +from typing import Any, overload from aiohttp import web from temporalio.client import Client @@ -99,10 +99,25 @@ def __init__( self.healthy = False self.health_check_port = health_check_port + @overload async def run( self, activities: list[Callable], workflow: type, + ) -> None: ... + + @overload + async def run( + self, + activities: list[Callable], + workflows: list[type], + ) -> None: ... + + async def run( + self, + activities: list[Callable], + workflow: type | None = None, + workflows: list[type] | None = None, ): await self.start_health_check_server() await self._register_agent() @@ -119,7 +134,7 @@ async def run( client=temporal_client, task_queue=self.task_queue, activity_executor=ThreadPoolExecutor(max_workers=self.max_workers), - workflows=[workflow], + workflows=[workflow] if workflows is None else workflows, activities=activities, workflow_runner=UnsandboxedWorkflowRunner(), max_concurrent_activities=self.max_concurrent_activities, From a8c5fa86d1cc759986776198a24c227b7b3c44b1 Mon Sep 17 00:00:00 2001 From: Jatong Su Date: Thu, 11 Sep 2025 13:36:59 -0400 Subject: [PATCH 2/3] require keyword arguments --- src/agentex/lib/core/temporal/workers/worker.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/agentex/lib/core/temporal/workers/worker.py b/src/agentex/lib/core/temporal/workers/worker.py index 25fdf974..331d8297 100644 --- a/src/agentex/lib/core/temporal/workers/worker.py +++ b/src/agentex/lib/core/temporal/workers/worker.py @@ -103,6 +103,7 @@ def __init__( async def run( self, activities: list[Callable], + *, workflow: type, ) -> None: ... @@ -110,12 +111,14 @@ async def run( async def run( self, activities: list[Callable], + *, workflows: list[type], ) -> None: ... async def run( self, activities: list[Callable], + *, workflow: type | None = None, workflows: list[type] | None = None, ): From 904f8c787bf9ce86b891ed7fd67f175e4b858dbc Mon Sep 17 00:00:00 2001 From: Jatong Su Date: Thu, 11 Sep 2025 13:53:28 -0400 Subject: [PATCH 3/3] raise error when workflow and workflows are none --- src/agentex/lib/core/temporal/workers/worker.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/agentex/lib/core/temporal/workers/worker.py b/src/agentex/lib/core/temporal/workers/worker.py index 331d8297..04babb54 100644 --- a/src/agentex/lib/core/temporal/workers/worker.py +++ b/src/agentex/lib/core/temporal/workers/worker.py @@ -133,6 +133,9 @@ async def run( if debug_enabled: logger.info("🐛 [WORKER] Temporal debug mode enabled - deadlock detection disabled") + if workflow is None and workflows is None: + raise ValueError("Either workflow or workflows must be provided") + worker = Worker( client=temporal_client, task_queue=self.task_queue,