The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: merge fallout — shutdown-tail verdict order, service-choice default, cron test path
teknium1c692973e3bc2
diff --git a/gateway/run_bootstrap.py b/gateway/run_bootstrap.pyindex 7f6c8a4f9c0..2ef3abd9af2 100644--- a/gateway/run_bootstrap.py+++ b/gateway/run_bootstrap.py@@ -357,7 +357,7 @@ async def _start_gateway_shutdown_tail(_planned_stop_watcher_stop: threading.Event, _planned_stop_watcher_thread: threading.Thread,_signal_initiated_shutdown: list) -> bool:"""Post-``wait_for_shutdown`` teardown; returns the process exit verdict (True = exit 0)."""- from gateway.run import (_CRON_SHUTDOWN_DRAIN_TIMEOUT, _HOUSEKEEPING_SHUTDOWN_DRAIN_TIMEOUT, _await_thread_exit, _best_effort, _exit_with_failure_verdict, _resolve_gateway_exit_verdict, _shutdown_mcp_servers_nonblocking, _stop_cron_provider, logger, suppress)+ from gateway.run import (_CRON_SHUTDOWN_DRAIN_TIMEOUT, _HOUSEKEEPING_SHUTDOWN_DRAIN_TIMEOUT, _await_thread_exit, _best_effort, _resolve_gateway_exit_verdict, _shutdown_mcp_servers_nonblocking, _stop_cron_provider, logger, suppress)# Control socket first: once shutdown begins we are no longer a truthful "serving here" answer and a# successor must be able to bind. Early-exit paths rely on the atexit cleanup_files hook instead.if _control_server is not None:@@ -371,8 +371,6 @@ async def _start_gateway_shutdown_tail(stop_nous_auth_keepalive()_best_effort(_stop_keepalive)- if _exit_with_failure_verdict(runner):- return False# Never join(): an in-flight cron delivery is a coroutine on THIS loop; a sync join would drop it.# Stop cron scheduler + housekeeping cleanly. These MUST be awaited cooperatively, not join()ed. A cron@@ -395,6 +393,8 @@ async def _start_gateway_shutdown_tail(with suppress(Exception):await _shutdown_mcp_servers_nonblocking()+ # The failure verdict comes AFTER the cooperative teardown: returning early here leaked the+ # cron ticker + housekeeping threads (and open MCP connections) for embedded callers (#12175).return _resolve_gateway_exit_verdict(runner, _signal_initiated_shutdown[0])diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex fcb08b59a0a..3b03b36361b 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -1905,6 +1905,7 @@ DEFAULT_CONFIG = {"export": {"otlp": {"enabled": False, "endpoint": "", "headers_env": {}}},},"gateway": { # Gateway settings (messaging platforms: Telegram, Discord, Slack, ...).+ "service_install_choice": None, # null | install | decline; never authorizes ordinary launch installation.# Seconds to let a SIGTERM-interrupted gateway agent unwind before adapter/database# teardown. Keep short so service-manager shutdowns don't exhaust their stop budget."signal_interrupt_grace_timeout": 1,diff --git a/tests/cron/test_cron_workdir.py b/tests/cron/test_cron_workdir.pyindex 73dc4fb86c8..f013fe5c148 100644--- a/tests/cron/test_cron_workdir.py+++ b/tests/cron/test_cron_workdir.py@@ -385,7 +385,7 @@ class TestRunJobTerminalCwd:monkeypatch.setattr(sched, "_run_job_script_with_claim_heartbeat", run_script)- success, *_ = sched.run_job(+ success, *_ = _run_owned_job({"id": "agent-script-workdir","name": "agent-script-workdir",@@ -393,7 +393,8 @@ class TestRunJobTerminalCwd:"script": "collect.py","workdir": str(workdir),"schedule_display": "manual",- }+ },+ tmp_path,)assert success is Truediff --git a/tests/gateway/test_startup_restart_race.py b/tests/gateway/test_startup_restart_race.pyindex abbadd10d87..6efcb950201 100644--- a/tests/gateway/test_startup_restart_race.py+++ b/tests/gateway/test_startup_restart_race.py@@ -380,7 +380,8 @@ async def test_failure_exit_still_stops_cron_housekeeping_and_mcp(monkeypatch):monkeypatch.setattr("hermes_cli.nous_auth_keepalive.stop_nous_auth_keepalive", lambda: None)runner = MagicMock(should_exit_with_failure=True, exit_reason="boom", exit_code=None)- result = await gateway_run._start_gateway_shutdown_tail(+ from gateway.run_bootstrap import _start_gateway_shutdown_tail+ result = await _start_gateway_shutdown_tail(runner, None, cron_stop, object(), threads[0], threads[1], watcher_stop, watcher, [False])assert result is False