From e4033b2baf681946bc36b3c02546866a28c7aae9 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 25 Mar 2026 12:47:51 -0700 Subject: [PATCH] fix(cli): catch KeyboardInterrupt during flush_memories on exit (#3025) KeyboardInterrupt inherits from BaseException, not Exception, so the except Exception: clauses wrapping flush_memories() on exit paths silently skipped the flush when the user pressed Ctrl+C. This could lose conversation memory. Change both call sites to except (Exception, KeyboardInterrupt): so the memory flush is attempted even during interrupt. Salvaged from PR #2855 by RufusLin (dropped unrelated bundled changes). --- cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli.py b/cli.py index f49fa2261..48e494728 100644 --- a/cli.py +++ b/cli.py @@ -2881,7 +2881,7 @@ class HermesCLI: if self.agent and self.conversation_history: try: self.agent.flush_memories(self.conversation_history) - except Exception: + except (Exception, KeyboardInterrupt): pass old_session_id = self.session_id @@ -7206,7 +7206,7 @@ class HermesCLI: if self.agent and self.conversation_history: try: self.agent.flush_memories(self.conversation_history) - except Exception: + except (Exception, KeyboardInterrupt): pass # Shut down voice recorder (release persistent audio stream) if hasattr(self, '_voice_recorder') and self._voice_recorder: