diff --git a/src/agentex/lib/cli/handlers/run_handlers.py b/src/agentex/lib/cli/handlers/run_handlers.py index a249dede..71880892 100644 --- a/src/agentex/lib/cli/handlers/run_handlers.py +++ b/src/agentex/lib/cli/handlers/run_handlers.py @@ -389,6 +389,10 @@ def create_agent_environment(manifest: AgentManifest) -> dict[str, str]: env_vars["WORKFLOW_NAME"] = temporal_config.name env_vars["WORKFLOW_TASK_QUEUE"] = temporal_config.queue_name + # Set health check port from temporal config + if manifest.agent.temporal and manifest.agent.temporal.health_check_port is not None: + env_vars["HEALTH_CHECK_PORT"] = str(manifest.agent.temporal.health_check_port) + if agent_config.env: for key, value in agent_config.env.items(): env_vars[key] = value diff --git a/src/agentex/lib/cli/templates/temporal/manifest.yaml.j2 b/src/agentex/lib/cli/templates/temporal/manifest.yaml.j2 index 5ec8cc5e..e5592aba 100644 --- a/src/agentex/lib/cli/templates/temporal/manifest.yaml.j2 +++ b/src/agentex/lib/cli/templates/temporal/manifest.yaml.j2 @@ -89,6 +89,10 @@ agent: # Convention: _task_queue queue_name: {{ queue_name }} + # Optional: Health check port for temporal worker + # Defaults to 80 if not specified + # health_check_port: 80 + # Optional: Credentials mapping # Maps Kubernetes secrets to environment variables # Common credentials include: diff --git a/src/agentex/lib/core/temporal/workers/worker.py b/src/agentex/lib/core/temporal/workers/worker.py index 60002243..46e14c0e 100644 --- a/src/agentex/lib/core/temporal/workers/worker.py +++ b/src/agentex/lib/core/temporal/workers/worker.py @@ -112,7 +112,7 @@ def __init__( task_queue, max_workers: int = 10, max_concurrent_activities: int = 10, - health_check_port: int = 80, + health_check_port: int = int(os.environ.get("HEALTH_CHECK_PORT")), plugins: list = [], ): self.task_queue = task_queue diff --git a/src/agentex/lib/environment_variables.py b/src/agentex/lib/environment_variables.py index 5740e0e0..d7b7e5db 100644 --- a/src/agentex/lib/environment_variables.py +++ b/src/agentex/lib/environment_variables.py @@ -32,6 +32,8 @@ class EnvVarKeys(str, Enum): # Workflow Configuration WORKFLOW_NAME = "WORKFLOW_NAME" WORKFLOW_TASK_QUEUE = "WORKFLOW_TASK_QUEUE" + # Temporal Worker Configuration + HEALTH_CHECK_PORT = "HEALTH_CHECK_PORT" # Auth Configuration AUTH_PRINCIPAL_B64 = "AUTH_PRINCIPAL_B64" # Build Information @@ -65,6 +67,9 @@ class EnvironmentVariables(BaseModel): # Workflow Configuration WORKFLOW_TASK_QUEUE: str | None = None WORKFLOW_NAME: str | None = None + # Temporal Worker Configuration + HEALTH_CHECK_PORT: int = 80 + # Auth Configuration AUTH_PRINCIPAL_B64: str | None = None # Build Information BUILD_INFO_PATH: str | None = None diff --git a/src/agentex/lib/types/agent_configs.py b/src/agentex/lib/types/agent_configs.py index 41b9ccb4..806136de 100644 --- a/src/agentex/lib/types/agent_configs.py +++ b/src/agentex/lib/types/agent_configs.py @@ -45,6 +45,7 @@ class TemporalConfig(BaseModel): enabled: Whether this agent uses Temporal workflows workflow: The temporal workflow configuration workflows: The list of temporal workflow configurations + health_check_port: Port for temporal worker health check endpoint """ enabled: bool = Field( @@ -58,6 +59,10 @@ class TemporalConfig(BaseModel): default=None, description="List of temporal workflow configurations. Used when enabled=true.", ) + health_check_port: int | None = Field( + default=None, + description="Port for temporal worker health check endpoint. Defaults to 80 if not specified.", + ) @validator("workflows") def validate_workflows_not_empty(cls, v):