hermes-agent/gateway
Teknium e9c1e757fe
fix(gateway): release evicted agent clients to stop RSS leak (#29298) (#41974)
_evict_cached_agent (the chokepoint for /new, /model, /undo, session
resets — 17 call sites) only popped the cache entry, dropping the
AIAgent reference without releasing its httpx client pool. AIAgent
holds reference cycles (callbacks, tool state) so CPython refcounting
does not free the client promptly; under steady gateway traffic the
held sockets + buffers accumulate and RSS climbs (the leak class behind

Now the chokepoint pops AND schedules a soft release_clients() on a
daemon thread (mirrors the cap-enforcer / idle-sweeper). Soft release
frees the client pool + per-turn child subagents but preserves the
session's terminal sandbox / browser / bg processes for resumption.
Mid-turn agents are skipped so a running request is never torn down.
Also fixes the no-lock branch which previously never popped at all.
2026-06-08 06:44:51 -07:00
..
assets
…
builtin_hooks
…
platforms fix(session): follow compression continuations for transcript reads 2026-06-07 23:57:20 -07:00
__init__.py
…
channel_directory.py
…
config.py
…
delivery.py
…
display_config.py
…
hooks.py
…
kanban_watchers.py refactor(gateway): extract kanban watcher loops into GatewayKanbanWatchersMixin (god-file Phase 3) 2026-06-07 23:14:18 -07:00
memory_monitor.py
…
mirror.py
…
pairing.py
…
platform_registry.py
…
restart.py
…
run.py fix(gateway): release evicted agent clients to stop RSS leak (#29298) (#41974) 2026-06-08 06:44:51 -07:00
runtime_footer.py
…
session.py
…
session_context.py
…
shutdown_forensics.py
…
slash_access.py
…
slash_commands.py refactor(gateway): extract 42 slash-command handlers into GatewaySlashCommandsMixin (god-file Phase 3b) 2026-06-08 01:25:35 -07:00
status.py
…
sticker_cache.py
…
stream_consumer.py
…
stream_dispatch.py
…
stream_events.py
…
whatsapp_identity.py
…