Skip to content

Self-improving AI Employees for everyone

feat(temporal): mode-aware per-queue concurrency defaults (Wave 17.5)

trohitg9b79e1ac1b48
diff --git a/.env.template b/.env.template
index e83064d8..ffa363e7 100644
--- a/.env.template
+++ b/.env.template
@@ -68,6 +68,13 @@ TEMPORAL_WORKER_POOL_ENABLED=false
# identity strings in the Temporal Web UI and per-mode concurrency
# defaults. Explicit TEMPORAL_<QUEUE>_CONCURRENCY overrides always win.
DEPLOYMENT_MODE=local
+# Per-queue concurrency overrides for the worker pool. Cloud defaults:
+# machina-default=20, rest-api=50, ai-heavy=4, code-exec=10,
+# triggers-poll=100, triggers-event=100, android=10, browser=4,
+# messaging=20 (DEPLOYMENT_MODE=local halves these, floor 1).
+# Examples:
+# 4-core laptop: TEMPORAL_AI_HEAVY_CONCURRENCY=2 TEMPORAL_BROWSER_CONCURRENCY=2 TEMPORAL_CODE_EXEC_CONCURRENCY=4
+# 32-core cloud: TEMPORAL_AI_HEAVY_CONCURRENCY=16 TEMPORAL_BROWSER_CONCURRENCY=8 TEMPORAL_CODE_EXEC_CONCURRENCY=32
# 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/services/temporal/worker.py b/server/services/temporal/worker.py
index 5d053004..b62aa448 100644
--- a/server/services/temporal/worker.py
+++ b/server/services/temporal/worker.py
@@ -324,13 +324,27 @@ class TemporalWorkerPool:
self._tasks: list[asyncio.Task] = []
def _concurrency_for(self, queue: str) -> int:
+ """Slots for a queue: explicit env override > mode-scaled default.
+
+ Wave 17.5: ``deployment_mode == "local"`` halves the per-queue
+ defaults (floor 1) — a dev laptop sharing 4-8 cores with an IDE
+ + browser shouldn't run cloud-sized activity fan-out. Explicit
+ ``TEMPORAL_<QUEUE>_CONCURRENCY`` env vars always win.
+ """
import os
env_key = f"TEMPORAL_{queue.upper().replace('-', '_')}_CONCURRENCY"
raw = os.environ.get(env_key)
if raw and raw.isdigit():
return int(raw)
- return self.DEFAULT_CONCURRENCY.get(queue, self.default_pool_size)
+
+ base = self.DEFAULT_CONCURRENCY.get(queue, self.default_pool_size)
+
+ from core.config import Settings
+
+ if Settings().deployment_mode == "local":
+ return max(1, base // 2)
+ return base
@property
def is_running(self) -> bool: