The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): apply startup-watchdog config to the already-armed handle
Kshitij Kapoor44eeef9a8370
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex 8ee4e5c9319..be5b02fdcdc 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -3226,10 +3226,12 @@ DEFAULT_CONFIG = {# Startup-liveness watchdog (OOF-298): plain daemon thread armed at# process entry for gateway runs, hard-exits 75 if the event loop is# not confirmed live within the deadline. The watchdog module itself- # is stdlib-only and armed before config can load, so these keys are- # BRIDGED to the internal HERMES_STARTUP_WATCHDOG /- # HERMES_STARTUP_WATCHDOG_TIMEOUT_S env vars by the gateway- # launchers — config.yaml is the user-facing surface.+ # is stdlib-only and armed before config can load, so run_gateway()+ # bridges these keys to the internal HERMES_STARTUP_WATCHDOG /+ # HERMES_STARTUP_WATCHDOG_TIMEOUT_S env vars AND applies them to the+ # already-armed handle (disarm on disable, disarm+re-arm on a config+ # timeout) — config.yaml is the user-facing surface; explicit env+ # values win as operator override."startup_watchdog": True,"startup_watchdog_timeout_seconds": 300,diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex d81ff4bfe01..2d10dc4d131 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -6453,12 +6453,24 @@ def run_gateway(verbose: int = 0, quiet: bool = False, replace: bool = False, fo# gateway.startup_watchdog_timeout_seconds); the env vars are the# internal bridge, needed because the argv fast-path arms before config# can load. Explicit env values (operator override) are respected.+ #+ # The argv fast-path has ALREADY armed on the standard `hermes gateway+ # run` path by the time this runs, and arm_startup_watchdog() is+ # idempotent (returns the live handle without re-reading env). So the+ # bridge alone is not enough: apply the config to the live handle —+ # disarm when disabled, disarm+re-arm when a config timeout should+ # replace the fast-path default. Re-arming is safe here: the heavy+ # import graph the fast-path guards is behind us, and the fresh handle+ # covers the remaining pre-loop startup with the configured deadline.try:from hermes_startup_watchdog import (ENV_STARTUP_WATCHDOG,ENV_STARTUP_WATCHDOG_TIMEOUT_S,arm_startup_watchdog,+ disarm_startup_watchdog,+ startup_watchdog_disabled,)+ _sw_timeout_bridged = Falsetry:from hermes_cli.config import load_config as _sw_load_config_gw_cfg = (_sw_load_config() or {}).get("gateway", {}) or {}@@ -6472,9 +6484,17 @@ def run_gateway(verbose: int = 0, quiet: bool = False, replace: bool = False, foand _sw_timeout is not None):os.environ[ENV_STARTUP_WATCHDOG_TIMEOUT_S] = str(_sw_timeout)+ _sw_timeout_bridged = Trueexcept Exception:pass- arm_startup_watchdog()+ if startup_watchdog_disabled():+ disarm_startup_watchdog()+ else:+ if _sw_timeout_bridged:+ # A config timeout must beat the fast-path default that an+ # already-armed handle resolved before config was readable.+ disarm_startup_watchdog()+ arm_startup_watchdog()except Exception:pass