Skip to content

The agent that grows with you

fix(cli): age out the gateway subagent roster when subagent.list keeps failing

kshitijk4poord6e93d6ab9bf
diff --git a/hermes_cli/gateway_tools.py b/hermes_cli/gateway_tools.py
index f6e23b4ca41..58469e7ae53 100644
--- a/hermes_cli/gateway_tools.py
+++ b/hermes_cli/gateway_tools.py
@@ -53,6 +53,7 @@ class GatewayProcessView:
self._lock = threading.Lock()
self.subagents: list = []
self._subagents_polled = 0.0
+ self._subagents_seen = 0.0
self._subagents_lock = threading.Lock()
self._tail = None
@@ -143,8 +144,11 @@ class GatewayProcessView:
self._subagents_polled = now
result = self.connection.call("subagent.list", session_id=self.session_id, timeout=5)
self.subagents = list((result or {}).get("subagents") or [])
+ self._subagents_seen = now
except (GatewayClientError, RuntimeError) as exc:
logger.debug("subagent.list failed: %s", exc)
+ if now - self._subagents_seen > _RETAIN_SECONDS:
+ self.subagents = [] # no answer for a minute: drop the rows and stop polling
finally:
self._subagents_lock.release()
return [dict(row) for row in self.subagents]