Bug Description
The Hindsight memory integration still emits aiohttp resource-leak warnings in a long-running Hermes gateway process even after the earlier Hindsight fix from PR #4762 (fix(hindsight): correct client constructor, add configurable base_url, and fix sequential tool dispatch).
The previous fix improved the plugin, but it did not eliminate the underlying Unclosed client session / Unclosed connector problem.
Symptoms
Observed repeatedly in gateway logs:
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x...>
ERROR asyncio: Unclosed connector
connector: <aiohttp.connector.TCPConnector object at 0x...>
Why this looks unresolved
The Hindsight plugin now has shutdown cleanup logic that calls self._client.aclose() during provider teardown, but the warnings still occur during normal runtime in the gateway logs, not only at final process shutdown.
Relevant code path in plugins/memory/hindsight/__init__.py:
if self._client is not None:
try:
if self._mode == "local_embedded":
try:
self._client.close()
except RuntimeError:
pass
else:
_run_sync(self._client.aclose())
except Exception:
pass
self._client = None
That suggests one of these is still happening:
- A client/session is created outside the lifecycle covered by provider shutdown.
- The async client owns an
aiohttp session that is not being fully closed in all paths.
- The shared background loop / cleanup timing still leaves transport resources orphaned.
- The leak happens during repeated memory operations in a long-running process, so shutdown cleanup is too late to prevent runtime warnings.
Steps to Reproduce
- Configure Hermes to use the Hindsight memory provider.
- Run the gateway as a long-lived process.
- Trigger memory activity (for example: normal chat flow with memory prefetch, or direct
hindsight_recall / hindsight_reflect / hindsight_retain usage).
- Check gateway logs.
Expected Behavior
No aiohttp resource leak warnings should appear during normal operation.
Actual Behavior
Gateway logs still show:
ERROR asyncio: Unclosed client session
ERROR asyncio: Unclosed connector
Sanitized Evidence
Example sanitized log sequence:
INFO plugins.memory.hindsight: Hindsight initialized: mode=cloud, api_url=http://YOUR_HINDSIGHT_HOST:8888, bank=main_hermes, budget=mid, memory_mode=hybrid, prefetch_method=recall, client=0.5.0
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x...>
ERROR asyncio: Unclosed connector
connections: ['deque([(<aiohttp.client_proto.ResponseHandler object at 0x...>, ...)])']
connector: <aiohttp.connector.TCPConnector object at 0x...>
This was observed multiple times across separate runtime windows, not as a one-off shutdown-only warning.
Environment
- Hermes Agent: current local deployment (exact upstream commit not verified before filing)
- Memory provider: Hindsight
- Hindsight client version reported by logs:
0.5.0
- Hindsight mode:
cloud / external server
- Python runtime: long-running gateway process
Additional Context
This looks like a follow-up / regression gap after PR #4762 rather than a brand-new issue. The previous repair addressed constructor/base_url/dispatch problems, but not the persistent aiohttp session cleanup problem.
It may be worth auditing:
- all Hindsight client creation sites,
- whether one
Hindsight instance internally owns multiple async sessions,
- whether cleanup happens on the same event loop that created the underlying resources,
- whether per-call temporary sessions survive even when the top-level client is reused.
Bug Description
The Hindsight memory integration still emits
aiohttpresource-leak warnings in a long-running Hermes gateway process even after the earlier Hindsight fix from PR #4762 (fix(hindsight): correct client constructor, add configurable base_url, and fix sequential tool dispatch).The previous fix improved the plugin, but it did not eliminate the underlying
Unclosed client session/Unclosed connectorproblem.Symptoms
Observed repeatedly in gateway logs:
Why this looks unresolved
The Hindsight plugin now has shutdown cleanup logic that calls
self._client.aclose()during provider teardown, but the warnings still occur during normal runtime in the gateway logs, not only at final process shutdown.Relevant code path in
plugins/memory/hindsight/__init__.py:That suggests one of these is still happening:
aiohttpsession that is not being fully closed in all paths.Steps to Reproduce
hindsight_recall/hindsight_reflect/hindsight_retainusage).Expected Behavior
No
aiohttpresource leak warnings should appear during normal operation.Actual Behavior
Gateway logs still show:
Sanitized Evidence
Example sanitized log sequence:
This was observed multiple times across separate runtime windows, not as a one-off shutdown-only warning.
Environment
0.5.0cloud/ external serverAdditional Context
This looks like a follow-up / regression gap after PR #4762 rather than a brand-new issue. The previous repair addressed constructor/base_url/dispatch problems, but not the persistent
aiohttpsession cleanup problem.It may be worth auditing:
Hindsightinstance internally owns multiple async sessions,