The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(gateway): keep run_shutdown.py and status.py inside their line caps
Teknium1efb1175ed18
diff --git a/gateway/run_runtime.py b/gateway/run_runtime.pyindex 5d0cb907605..2277426e0e6 100644--- a/gateway/run_runtime.py+++ b/gateway/run_runtime.py@@ -272,6 +272,12 @@ def stop_managed_turns(runner):return sum(stop_authority_turns(authority) for authority in _authorities(runner))+def interrupt_side_agents(runner, reason):+ """Whole-runtime shutdown: interrupt every counted side agent (``session_runtime_workers``)."""+ from gateway.session_runtime_workers import interrupt_side_agents as interrupt+ return interrupt(runner, reason)++async def _retire_profile_authority(authority, timeout=None):"""Stop profile-local services and turns before its ownership is released.diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.pyindex f205fedce12..e1f7285b914 100644--- a/gateway/run_shutdown.py+++ b/gateway/run_shutdown.py@@ -28,8 +28,7 @@ from gateway.restart import (effective_stop_drain_timeout, effective_stop_watchdog_delay, resolve_cron_drain_budget)from gateway.run_common import _UNSET-from gateway.run_runtime import managed_turn_count, stop_managed_turns-from gateway.session_runtime_workers import interrupt_side_agents+from gateway.run_runtime import interrupt_side_agents, managed_turn_count, stop_managed_turnsfrom gateway.run_shutdown_session_end import GatewaySessionEndMixinfrom gateway.shutdown_watchdog import arm_shutdown_watchdog, resolve_shutdown_watchdog_delay@@ -857,13 +856,11 @@ class GatewayShutdownMixin(GatewaySessionEndMixin):with _log_suppressed(logging.DEBUG, "Failed interrupting agent during shutdown: %s"):request_hard_interrupt(agent, reason, tool_reason=_INTERRUPT_TOOL_REASON_GATEWAY_SHUTDOWN)logger.debug("Interrupted running agent for session %s during shutdown", session_key)- # API-server / desk / managed-worker turns and side agents never enter _running_agents: the- # drain waited on them.+ # API/desk/managed-worker turns and side agents never enter _running_agents: the drain waited.for count, what in ((self._interrupt_api_server_runs(reason), "api_server run(s)"),(self._interrupt_deferred_agent_workers(reason), "deferred agent worker(s)"),- (stop_managed_turns(self), "managed-worker turn(s)"),- (interrupt_side_agents(self, reason), "side agent(s)"),+ (stop_managed_turns(self), "managed-worker turn(s)"), (interrupt_side_agents(self, reason), "side agent(s)"),):if count:logger.debug("Interrupted %d %s during shutdown", count, what)diff --git a/gateway/status.py b/gateway/status.pyindex 5fa2a99238e..9d1a90b16c0 100644--- a/gateway/status.py+++ b/gateway/status.py@@ -494,15 +494,8 @@ def _get_process_start_time(pid: int) -> Optional[int]:except (FileNotFoundError, IndexError, PermissionError, ValueError, OSError):pass- # No /proc (macOS / Windows): psutil is a hard dependency and exposes a- # cross-platform creation time. Quantize to centiseconds so repeated reads- # of the same process compare equal without float-precision fragility.- # ``process_birth`` is the kernel start on macOS: psutil's ``create_time()``- # there shifts by a boot-time reference frozen per calling process, so after a- # clock step a long-lived gateway and a fresh worker fingerprinted the same- # live PID differently (Kanban ``_watch_submitter`` then exited; #140580).- # With no step (|drift| < 1 s) psutil returns the kernel start unchanged, so- # stored fingerprints keep matching.+ # No /proc (macOS / Windows): psutil, quantized to centiseconds for stable equality.+ # process_birth: macOS's clock-step-stable kernel start (#140580); unchanged with no step.try:import psutil # type: ignorefrom hermes_cli.process_identity import process_birth