Skip to content

feat: make workflow execution timeout configurable via env var#348

Merged
danielmillerp merged 1 commit intonextfrom
dm/configurable-workflow-execution-timeout
May 7, 2026
Merged

feat: make workflow execution timeout configurable via env var#348
danielmillerp merged 1 commit intonextfrom
dm/configurable-workflow-execution-timeout

Conversation

@danielmillerp
Copy link
Copy Markdown
Contributor

@danielmillerp danielmillerp commented May 7, 2026

Summary

  • Adds a new WORKFLOW_EXECUTION_TIMEOUT_SECONDS environment variable that controls the Temporal execution_timeout used when TemporalTaskService.submit_task starts an agent's workflow.
  • Default remains 86400 (24h), so existing deployments are unchanged.
  • Agents whose tasks legitimately run longer than 24h (long-running automations, multi-day human-in-the-loop flows, etc.) can now extend the cap by setting the env var on their deployment, e.g. WORKFLOW_EXECUTION_TIMEOUT_SECONDS=1209600 for 14 days.

Why

Previously the SDK hardcoded execution_timeout=timedelta(seconds=86400) as the default in TemporalClient.start_workflow, and TemporalTaskService.submit_task did not override it. Any agent intended to run longer than 24h would have its workflow forcibly timed out by Temporal even when the agent's own internal task timeout was longer.

Per Temporal's documented guidance, Workflow Execution Timeout has no upper bound — workflows are designed to be long-running — so increasing the cap is safe.

Test plan

  • Unit: existing tests still pass (no test directly covered submit_task's execution_timeout argument before this change; behavior preserved by the 86400 default).
  • Manual: deploy an agent with WORKFLOW_EXECUTION_TIMEOUT_SECONDS set to a longer value and confirm the Temporal WorkflowExecutionTimeout reflects the override.

🤖 Generated with Claude Code

Greptile Summary

  • Introduces WORKFLOW_EXECUTION_TIMEOUT_SECONDS env var (default 86400, validated gt=0) so agents with long-running workflows can raise the Temporal execution timeout without code changes.
  • Wires the value directly into TemporalTaskService.submit_task via execution_timeout=timedelta(seconds=...), preserving the previous 24 h default for existing deployments.
  • Extends the tutorial-agent CI workflow to also trigger on PRs targeting the next branch.

Confidence Score: 5/5

Safe to merge — changes are minimal, backwards-compatible, and correctly validated.

All three changed files are clean: the new env var has proper gt=0 Pydantic validation (addressing the previously flagged concern), the timeout is wired correctly into Temporal's start_workflow, and the CI change is intentional. No P0 or P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/agentex/lib/environment_variables.py Adds WORKFLOW_EXECUTION_TIMEOUT_SECONDS to EnvVarKeys enum and EnvironmentVariables model with Field(default=86400, gt=0) validation; previously-flagged missing lower-bound guard is present.
src/agentex/lib/core/temporal/services/temporal_task_service.py Wires the new env var into start_workflow as execution_timeout=timedelta(seconds=...) and imports timedelta from datetime; logic is straightforward and correct.
.github/workflows/agentex-tutorials-test.yml Adds next to the pull_request branch filter so tutorial tests run on PRs targeting next; push trigger intentionally left as main-only.

Sequence Diagram

sequenceDiagram
    participant Env as EnvironmentVariables
    participant TTS as TemporalTaskService
    participant TC as TemporalClient
    participant T as Temporal Server

    Note over Env: WORKFLOW_EXECUTION_TIMEOUT_SECONDS loaded from env (default 86400, gt=0)
    TTS->>Env: read WORKFLOW_EXECUTION_TIMEOUT_SECONDS
    TTS->>TC: "start_workflow(..., execution_timeout=timedelta(seconds=N))"
    TC->>T: "StartWorkflowExecution (WorkflowExecutionTimeout = N s)"
    T-->>TC: workflow_id
    TC-->>TTS: workflow_id
Loading

Reviews (3): Last reviewed commit: "feat: make workflow execution timeout co..." | Re-trigger Greptile

Comment thread src/agentex/lib/environment_variables.py Outdated
@danielmillerp danielmillerp force-pushed the dm/configurable-workflow-execution-timeout branch from bcb7272 to 1e21af5 Compare May 7, 2026 21:25
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.
@danielmillerp danielmillerp force-pushed the dm/configurable-workflow-execution-timeout branch from 1e21af5 to d2fbe00 Compare May 7, 2026 21:29
@danielmillerp danielmillerp merged commit 4094708 into next May 7, 2026
35 checks passed
@danielmillerp danielmillerp deleted the dm/configurable-workflow-execution-timeout branch May 7, 2026 22:32
@stainless-app stainless-app Bot mentioned this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants