fix: silent memory flush failure on /new and /resume commands#5640
Merged
teknium1 merged 1 commit intoNousResearch:mainfrom Apr 6, 2026
Merged
Conversation
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 9c96f66, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Sessions reset by
/newand/resumenever trigger memory extraction. The auto-expiry flush also had this bug (fixed in 9c96f66) but two call sites were missed.The root cause is a signature mismatch:
_async_flush_memories(self, old_session_id: str)accepts one parameter, yet the callers pass two:```python
gateway/run.py:3247 — /new handler
self._async_flush_memories(old_entry.session_id, session_key)
^^^^^^^^^^^^^^^^^ TypeError
gateway/run.py:4989 — /resume handler
self._async_flush_memories(current_entry.session_id, session_key)
^^^^^^^^^^^^^^^^^ TypeError
```
The
TypeErroris silently caught atDEBUGlevel and swallowed, so memory extraction is never attempted.Why this matters
Users who actively reset sessions with
/new(the most common way to start fresh) or switch sessions with/resumeget zero memory consolidation. Only automatic idle expiry (which was fixed) actually flushes. This means important conversation outcomes — preferences learned, decisions made, workflows discovered — are lost when the user manually resets.Fix
Remove the stray
session_keyargument from both call sites, matching the already-correct expiry loop at line 1312:gateway/run.pysession_keyfrom/newhandlergateway/run.pysession_keyfrom/resumehandlertests/gateway/test_resume_command.pyImpact
session_keywas never consumed inside the flush function — it only usessession_idto load transcripts.Reproduction
Any
/newor/resumeon any platform (Telegram, Discord, CLI, etc.). Thememory_flushedflag on expired sessions never gets set because the flush task crashes before running.