Skip to content

The agent that grows with you

fix(gateway): log api_server runs in the drain-floor wait and doc the floor

kshitijk4poorff9e0f8c6429
diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.py
index e0dd54c01a8..240caab5e74 100644
--- a/gateway/run_shutdown.py
+++ b/gateway/run_shutdown.py
@@ -1907,11 +1907,11 @@ class GatewayShutdownMixin:
_cron_timeout = resolve_cron_drain_budget(
timeout, _cron_drain_cfg, watchdog_delay=_cron_leash, elapsed=ctx.elapsed(),
)
- if _cron_at_start and _cron_timeout > timeout:
+ if (_cron_at_start or _api_at_start) and _cron_timeout > timeout:
logger.info(
- "Shutdown drain: %d in-flight cron job(s) — waiting up to "
+ "Shutdown drain: %d in-flight cron job(s), %d api_server run(s) — waiting up to "
"%.0fs for them (cron_drain_timeout=%.0fs, restart_drain_timeout=%.0fs)",
- _cron_at_start, _cron_timeout, _cron_drain_cfg, timeout,
+ _cron_at_start, _api_at_start, _cron_timeout, _cron_drain_cfg, timeout,
)
_drain_started_at = time.monotonic()
ctx.active_agents, ctx.timed_out = await self._drain_active_agents(timeout, _cron_timeout)
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 7f4db9e3b9d..c15e3888089 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -109,13 +109,11 @@ DEFAULT_CONFIG = {
# TimeoutStopSec or risk SIGKILL mid-cleanup; for /restart prefer restart_after_turn_timeout
# so turns finish BEFORE stop().
"restart_drain_timeout": 0,
- # Cron-only floor under the stop()/drain wait (seconds). Interrupted chat turns resume on
- # the next message, but an interrupted cron run is recorded as a permanent failure, so it
- # must not inherit restart_drain_timeout's 0. Clamped to the shutdown-watchdog leash minus
- # teardown headroom (~50s unless TimeoutStopSec is raised). 0 = opt out.
- # A chat turn interrupted by a restart is announced to the user and resumed on their next message;
- # an interrupted cron run is written to jobs.json as a permanent failure that nobody is waiting on,
- # so it must not inherit restart_drain_timeout's 0 (#82161).
+ # Floor under the stop()/drain wait (seconds) for cron jobs and api_server runs. Interrupted
+ # chat turns resume on the next message, but an interrupted cron run is recorded as a
+ # permanent failure and an interrupted /v1 run fails its waiting caller, so neither may
+ # inherit restart_drain_timeout's 0 (#82161, #132989). Clamped to the shutdown-watchdog
+ # leash minus teardown headroom (~50s unless TimeoutStopSec is raised). 0 = opt out.
"cron_drain_timeout": 30,
# In-band restart (/restart, SIGUSR1): refuse new work, then wait up to this many seconds
# for in-flight agents/cron/api runs to finish before stop(). 0 = enter stop() at once. 30