Skip to content

Commit bcb7272

Browse files
committed
feat: make workflow execution timeout configurable via env var
Adds WORKFLOW_EXECUTION_TIMEOUT_SECONDS so agents whose tasks run longer than the previous hardcoded 24h cap can extend the timeout without forking the SDK. Default behavior (24h) is unchanged.
1 parent f03fb3d commit bcb7272

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/agentex/lib/core/temporal/services/temporal_task_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from typing import Any
4+
from datetime import timedelta
45

56
from agentex.types.task import Task
67
from agentex.types.agent import Agent
@@ -41,6 +42,7 @@ async def submit_task(self, agent: Agent, task: Task, params: dict[str, Any] | N
4142
),
4243
id=task.id,
4344
task_queue=self._env_vars.WORKFLOW_TASK_QUEUE,
45+
execution_timeout=timedelta(seconds=self._env_vars.WORKFLOW_EXECUTION_TIMEOUT_SECONDS),
4446
)
4547

4648
async def get_state(self, task_id: str) -> WorkflowState:

src/agentex/lib/environment_variables.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class EnvVarKeys(str, Enum):
3232
# Workflow Configuration
3333
WORKFLOW_NAME = "WORKFLOW_NAME"
3434
WORKFLOW_TASK_QUEUE = "WORKFLOW_TASK_QUEUE"
35+
WORKFLOW_EXECUTION_TIMEOUT_SECONDS = "WORKFLOW_EXECUTION_TIMEOUT_SECONDS"
3536
# Temporal Worker Configuration
3637
HEALTH_CHECK_PORT = "HEALTH_CHECK_PORT"
3738
# Auth Configuration
@@ -74,6 +75,10 @@ class EnvironmentVariables(BaseModel):
7475
# Workflow Configuration
7576
WORKFLOW_TASK_QUEUE: str | None = None
7677
WORKFLOW_NAME: str | None = None
78+
# Maximum total time (in seconds) a workflow execution can run, including
79+
# retries and continue-as-new. Defaults to 24h to bound runaway workflows;
80+
# agents with longer-running tasks should override this.
81+
WORKFLOW_EXECUTION_TIMEOUT_SECONDS: int = 86400
7782
# Temporal Worker Configuration
7883
HEALTH_CHECK_PORT: int = 80
7984
# Auth Configuration

0 commit comments

Comments
 (0)