Skip to content

fix(cli): catch KeyboardInterrupt during flush_memories on exit#3025

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769
Mar 25, 2026
Merged

fix(cli): catch KeyboardInterrupt during flush_memories on exit#3025
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

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.

Changes except Exception: to except (Exception, KeyboardInterrupt): at both call sites (line ~2884 and ~7209 in cli.py).

Salvaged from PR #2855 by @RufusLin (dropped unrelated bundled hermes_context_mgmt imports that would have broken the build).

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).
@teknium1 teknium1 merged commit e4033b2 into main Mar 25, 2026
InB4DevOps pushed a commit to InB4DevOps/hermes-agent that referenced this pull request Mar 25, 2026
…Research#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 NousResearch#2855 by RufusLin (dropped unrelated bundled changes).
dieutx added a commit to dieutx/hermes-agent that referenced this pull request Mar 26, 2026
except Exception does not catch KeyboardInterrupt (inherits from
BaseException). A second Ctrl+C during exit cleanup aborts pending
writes silently:

- cli.py: honcho.shutdown() and end_session() in the finally exit block
- run_agent.py: _flush_honcho_on_exit atexit handler
- cron/scheduler.py: end_session() + close() in job finally block

Change to except (Exception, KeyboardInterrupt) at all five sites,
matching the pattern from PR NousResearch#3025 which fixed the same issue in
flush_memories().
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…Research#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 NousResearch#2855 by RufusLin (dropped unrelated bundled changes).
StreamOfRon pushed a commit to StreamOfRon/hermes-agent that referenced this pull request Mar 29, 2026
…Research#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 NousResearch#2855 by RufusLin (dropped unrelated bundled changes).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant