mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
fix(gateway): clean up cached agents on shutdown (#11205)
This commit is contained in:
parent
778fd1898e
commit
bf05b8f4a2
2 changed files with 227 additions and 0 deletions
|
|
@ -2800,6 +2800,23 @@ class GatewayRunner:
|
|||
|
||||
self._finalize_shutdown_agents(active_agents)
|
||||
|
||||
# Also shut down memory providers on idle cached agents.
|
||||
# _finalize_shutdown_agents only handles agents that were
|
||||
# mid-turn at drain time; the _agent_cache may still hold
|
||||
# idle agents whose MemoryProviders never received
|
||||
# on_session_end().
|
||||
_cache_lock = getattr(self, "_agent_cache_lock", None)
|
||||
_cache = getattr(self, "_agent_cache", None)
|
||||
if _cache_lock is not None and _cache is not None:
|
||||
with _cache_lock:
|
||||
_idle_agents = list(_cache.values())
|
||||
_cache.clear()
|
||||
for _entry in _idle_agents:
|
||||
_agent = (
|
||||
_entry[0] if isinstance(_entry, tuple) else _entry
|
||||
)
|
||||
self._cleanup_agent_resources(_agent)
|
||||
|
||||
for platform, adapter in list(self.adapters.items()):
|
||||
try:
|
||||
await adapter.cancel_background_tasks()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue