Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,15 @@ async def _stop_impl() -> None:
self._running = False
self._draining = True

# Write clean-shutdown marker EARLY — before drain begins — so that
# even if systemd SIGKILLs us due to TimeoutStopSec (60s), the marker
# already exists. This prevents suspend_recently_active() from
# auto-resetting sessions on the next startup.
try:
(_hermes_home / ".clean_shutdown").touch()
except Exception:
pass

# Notify all chats with active agents BEFORE draining.
# Adapters are still connected here, so messages can be sent.
await self._notify_active_sessions_of_shutdown()
Expand Down Expand Up @@ -2378,14 +2387,10 @@ async def _stop_impl() -> None:
from gateway.status import remove_pid_file
remove_pid_file()

# Write a clean-shutdown marker so the next startup knows this
# wasn't a crash. suspend_recently_active() only needs to run
# after unexpected exits. However, if the drain timed out and
# agents were force-interrupted, their sessions may be in an
# incomplete state (trailing tool response, no final assistant
# message). Skip the marker in that case so the next startup
# suspends those sessions — giving users a clean slate instead
# of resuming a half-finished tool loop.
# Clean-shutdown marker was already written at the top of _stop_impl()
# (before drain), so it exists even if systemd SIGKILLs us during a
# long drain. Re-touch here as a no-op for completeness.
# (See the early write above for the real safeguard.)
if not timed_out:
try:
(_hermes_home / ".clean_shutdown").touch()
Expand Down
1 change: 1 addition & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"zzn+pa@zzn.im": "xinbenlv",
"zaynjarvis@gmail.com": "ZaynJarvis",
"zhiheng.liu@bytedance.com": "ZaynJarvis",
"brantzh6@users.nore.github.com": "brantzh6",
}


Expand Down
Loading