From 0f9aa570695df978d8256b93a462c1c443e4769f Mon Sep 17 00:00:00 2001 From: ryanautomated Date: Mon, 6 Apr 2026 22:10:47 +0100 Subject: [PATCH] fix: silent memory flush failure on /new and /resume commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The _async_flush_memories() helper accepts (session_id) but both the /new and /resume handlers passed two arguments (session_id, session_key). The TypeError was silently swallowed at DEBUG level, so memory extraction never ran when users typed /new or /resume. One call site (the session expiry watcher) was already fixed in 9c96f669, but /new and /resume were missed. - gateway/run.py:3247 — remove stray session_key from /new handler - gateway/run.py:4989 — remove stray session_key from /resume handler - tests/gateway/test_resume_command.py:222 — update test assertion --- gateway/run.py | 4 ++-- tests/gateway/test_resume_command.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gateway/run.py b/gateway/run.py index 731bc8c03..82cb10b4e 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -3244,7 +3244,7 @@ class GatewayRunner: old_entry = self.session_store._entries.get(session_key) if old_entry: _flush_task = asyncio.create_task( - self._async_flush_memories(old_entry.session_id, session_key) + self._async_flush_memories(old_entry.session_id) ) self._background_tasks.add(_flush_task) _flush_task.add_done_callback(self._background_tasks.discard) @@ -4990,7 +4990,7 @@ class GatewayRunner: # Flush memories for current session before switching try: _flush_task = asyncio.create_task( - self._async_flush_memories(current_entry.session_id, session_key) + self._async_flush_memories(current_entry.session_id) ) self._background_tasks.add(_flush_task) _flush_task.add_done_callback(self._background_tasks.discard) diff --git a/tests/gateway/test_resume_command.py b/tests/gateway/test_resume_command.py index 739bc149b..dc788f74f 100644 --- a/tests/gateway/test_resume_command.py +++ b/tests/gateway/test_resume_command.py @@ -201,8 +201,8 @@ class TestHandleResumeCommand: db.close() @pytest.mark.asyncio - async def test_resume_flushes_memories_with_gateway_session_key(self, tmp_path): - """Resume should preserve the gateway session key for Honcho flushes.""" + async def test_resume_flushes_memories(self, tmp_path): + """Resume should flush memories from the current session before switching.""" from hermes_state import SessionDB db = SessionDB(db_path=tmp_path / "state.db") @@ -221,6 +221,5 @@ class TestHandleResumeCommand: runner._async_flush_memories.assert_called_once_with( "current_session_001", - _session_key_for_event(event), ) db.close()