mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(delegate): move heartbeat thread start inside try block to prevent orphan
_heartbeat_thread.start() was called before the try/finally block that contains _heartbeat_stop.set(). If _register_subagent() or any code between .start() and try: raised an exception, the finally block would never run — leaving the heartbeat thread as an orphan that continues calling _touch_activity() on the parent agent, incorrectly resetting gateway timeout counters. Move _heartbeat_thread.start() to be the first statement inside the try block so the finally block always reaches _heartbeat_stop.set() regardless of how the child run completes or fails. Root cause: heartbeat start outside try/finally scope Impact: orphan heartbeat thread incorrectly resets parent gateway timeouts
This commit is contained in:
parent
42070ecefb
commit
2d7182f72c
1 changed files with 1 additions and 1 deletions
|
|
@ -1431,7 +1431,6 @@ def _run_single_child(
|
||||||
pass
|
pass
|
||||||
|
|
||||||
_heartbeat_thread = threading.Thread(target=_heartbeat_loop, daemon=True)
|
_heartbeat_thread = threading.Thread(target=_heartbeat_loop, daemon=True)
|
||||||
_heartbeat_thread.start()
|
|
||||||
|
|
||||||
# Register the live agent in the module-level registry so the TUI can
|
# Register the live agent in the module-level registry so the TUI can
|
||||||
# target it by subagent_id (kill, pause, status queries). Unregistered
|
# target it by subagent_id (kill, pause, status queries). Unregistered
|
||||||
|
|
@ -1462,6 +1461,7 @@ def _run_single_child(
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
_heartbeat_thread.start()
|
||||||
if child_progress_cb:
|
if child_progress_cb:
|
||||||
try:
|
try:
|
||||||
child_progress_cb("subagent.start", preview=goal)
|
child_progress_cb("subagent.start", preview=goal)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue