Skip to content

Commit 4094708

Browse files
feat: make workflow execution timeout configurable via env var (#348)
1 parent f03fb3d commit 4094708

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/agentex-tutorials-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test Tutorial Agents
22

33
on:
44
pull_request:
5-
branches: [main]
5+
branches: [main, next]
66
push:
77
branches: [main]
88
workflow_dispatch:

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pathlib import Path
77

88
from dotenv import load_dotenv
9+
from pydantic import Field
910

1011
from agentex.lib.utils.logging import make_logger
1112
from agentex.lib.utils.model_utils import BaseModel
@@ -32,6 +33,7 @@ class EnvVarKeys(str, Enum):
3233
# Workflow Configuration
3334
WORKFLOW_NAME = "WORKFLOW_NAME"
3435
WORKFLOW_TASK_QUEUE = "WORKFLOW_TASK_QUEUE"
36+
WORKFLOW_EXECUTION_TIMEOUT_SECONDS = "WORKFLOW_EXECUTION_TIMEOUT_SECONDS"
3537
# Temporal Worker Configuration
3638
HEALTH_CHECK_PORT = "HEALTH_CHECK_PORT"
3739
# Auth Configuration
@@ -74,6 +76,11 @@ class EnvironmentVariables(BaseModel):
7476
# Workflow Configuration
7577
WORKFLOW_TASK_QUEUE: str | None = None
7678
WORKFLOW_NAME: str | None = None
79+
# Maximum total time (in seconds) a workflow execution can run, including
80+
# retries and continue-as-new. Defaults to 24h to bound runaway workflows;
81+
# agents with longer-running tasks should override this. Must be > 0 — a
82+
# zero or negative timedelta would cause every submitted workflow to fail.
83+
WORKFLOW_EXECUTION_TIMEOUT_SECONDS: int = Field(default=86400, gt=0)
7784
# Temporal Worker Configuration
7885
HEALTH_CHECK_PORT: int = 80
7986
# Auth Configuration

0 commit comments

Comments
 (0)