The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): name the turn-pool size and drop the test-local shutdown helper
kshitijk4poor8febf1dcea74
diff --git a/gateway/run.py b/gateway/run.pyindex 86b6de53e2d..7a34a1e95fd 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -56,6 +56,8 @@ _TELEGRAM_CONNECT_TIMEOUT_SECS_DEFAULT = 180.0# offline update queue, #46621)._TELEGRAM_INITIAL_CONNECT_TIMEOUT_SECS_DEFAULT = 45.0_ADAPTER_DISCONNECT_TIMEOUT_SECS_DEFAULT = 5.0+# Size of the pool that runs turn bodies (blocking agent work).+_TURN_MAX_WORKERS = 10# Size of the separate pool for best-effort session HOUSEKEEPING (finalize hooks, agent cleanup).# It is separate from the turn pool because housekeeping callers ABANDON their worker on timeout —# see _run_housekeeping_in_executor.@@ -4321,7 +4323,7 @@ class GatewayRunner(def _get_executor(self) -> concurrent.futures.ThreadPoolExecutor:"""Return the gateway-owned executor for blocking agent work."""- return GatewayRunner._get_or_create_pool(self, "_executor", 10, "hermes-gateway")+ return GatewayRunner._get_or_create_pool(self, "_executor", _TURN_MAX_WORKERS, "hermes-gateway")def _get_housekeeping_executor(self) -> concurrent.futures.ThreadPoolExecutor:"""Return the gateway-owned executor for best-effort session housekeeping."""diff --git a/tests/gateway/test_executor_pool_isolation.py b/tests/gateway/test_executor_pool_isolation.pyindex 1c91ca04ba3..2111da67ef0 100644--- a/tests/gateway/test_executor_pool_isolation.py+++ b/tests/gateway/test_executor_pool_isolation.py@@ -23,9 +23,7 @@ import timeimport pytest-from gateway.run import GatewayRunner--_TURN_POOL_SIZE = 10+from gateway.run import _TURN_MAX_WORKERS, GatewayRunnerdef _runner(cleanup=None, *, cleanup_timeout=0.5):@@ -40,13 +38,6 @@ def _runner(cleanup=None, *, cleanup_timeout=0.5):return runner-def _stop(runner):- for attr in ("_executor", "_housekeeping_executor"):- pool = getattr(runner, attr, None)- if pool is not None:- pool.shutdown(wait=False, cancel_futures=True)--def _run_housekeeping(runner, func, *args):"""Submit like the production callers do; fall back to the shared pool if the fix is absent."""submit = getattr(runner, "_run_housekeeping_in_executor", runner._run_in_executor_with_context)@@ -79,7 +70,7 @@ def test_abandoned_housekeeping_cannot_delay_a_turn_body():runner = _runner(wedged_cleanup)# Enough to fill the turn pool outright if housekeeping still lands on it.- abandoned = _TURN_POOL_SIZE+ abandoned = _TURN_MAX_WORKERSasync def exercise():await _abandon_housekeeping(runner, abandoned, runner._CLEANUP_TIMEOUT_S)@@ -102,7 +93,7 @@ def test_abandoned_housekeeping_cannot_delay_a_turn_body():latency = asyncio.run(exercise())finally:wedge.set()- _stop(runner)+ runner._shutdown_executor()assert latency < 1.0, f"turn body waited {latency:.2f}s behind abandoned housekeeping"