Skip to content

Self-improving AI Employees for everyone

feat(temporal): DEPLOYMENT_MODE setting + explicit worker identity (Wave 17.4)

trohitga8ab8329b9b8
diff --git a/.env.template b/.env.template
index b7edfe79..e83064d8 100644
--- a/.env.template
+++ b/.env.template
@@ -63,6 +63,11 @@ TEMPORAL_AGENT_WORKFLOW_ENABLED=true
# single 100-slot pool on machina-tasks. Rollback channel: set false +
# restart — activities route back to the manager worker unchanged.
TEMPORAL_WORKER_POOL_ENABLED=false
+# Deployment topology hint: local (dev laptop; sleeps; halved per-queue
+# concurrency) | cloud (machina deploy VM) | self_hosted. Drives worker
+# identity strings in the Temporal Web UI and per-mode concurrency
+# defaults. Explicit TEMPORAL_<QUEUE>_CONCURRENCY overrides always win.
+DEPLOYMENT_MODE=local
# gRPC frontend port the CLI dev server binds (``--port``). Default per
# https://docs.temporal.io/references/configuration.
TEMPORAL_FRONTEND_GRPC_PORT=7233
diff --git a/server/core/config.py b/server/core/config.py
index d6222261..fd7a127a 100644
--- a/server/core/config.py
+++ b/server/core/config.py
@@ -108,6 +108,18 @@ class Settings(BaseSettings):
default=False,
env="TEMPORAL_WORKER_POOL_ENABLED",
)
+ # Wave 17.4: deployment topology hint. Drives worker identity
+ # strings (visible in Temporal Web UI -> Workers) and per-mode
+ # concurrency defaults (local laptops get half the per-queue slots
+ # of an always-on cloud VM; explicit TEMPORAL_<QUEUE>_CONCURRENCY
+ # env vars always win).
+ # local — developer machine; sleeps/hibernates; 4-8 cores
+ # cloud — always-on server (machina deploy)
+ # self_hosted — user-managed always-on box
+ deployment_mode: Literal["local", "cloud", "self_hosted"] = Field(
+ default="local",
+ env="DEPLOYMENT_MODE",
+ )
# gRPC frontend port — the port ``temporal server start-dev``
# exposes for clients + supervisor readiness probe. Sourced from
diff --git a/server/services/temporal/worker.py b/server/services/temporal/worker.py
index 93aa528f..fdb20ae8 100644
--- a/server/services/temporal/worker.py
+++ b/server/services/temporal/worker.py
@@ -51,6 +51,19 @@ def _graceful_shutdown_timeout() -> timedelta:
return timedelta(seconds=Settings().temporal_graceful_shutdown_seconds)
+def _worker_identity(queue: str) -> str:
+ """Wave 17.4: explicit worker identity for Temporal Web UI ops.
+
+ Default SDK identity is ``<pid>@<hostname>`` which makes the
+ Workers tab unreadable once the per-queue pool runs 9 workers on
+ one host. ``machina-<queue>-<deployment_mode>`` names the role and
+ the topology at a glance.
+ """
+ from core.config import Settings
+
+ return f"machina-{queue}-{Settings().deployment_mode}"
+
+
def create_runtime() -> Runtime:
"""Create a Temporal runtime with worker heartbeating disabled.
@@ -178,6 +191,7 @@ class TemporalWorkerManager:
max_concurrent_activities=self.pool_size,
max_concurrent_workflow_tasks=10,
graceful_shutdown_timeout=_graceful_shutdown_timeout(),
+ identity=_worker_identity(self.task_queue),
)
logger.info(
"Registered Temporal activities",
@@ -338,6 +352,7 @@ class TemporalWorkerPool:
max_concurrent_activities=concurrency,
max_concurrent_workflow_tasks=10,
graceful_shutdown_timeout=_graceful_shutdown_timeout(),
+ identity=_worker_identity(queue),
)
task = asyncio.create_task(worker.run(), name=f"worker-{queue}")
self._workers.append(worker)