Skip to content

fix: silent memory flush failure on /new and /resume commands#5640

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
ryanautomated:fix/silent-memory-flush-new-resume
Apr 6, 2026
Merged

fix: silent memory flush failure on /new and /resume commands#5640
teknium1 merged 1 commit intoNousResearch:mainfrom
ryanautomated:fix/silent-memory-flush-new-resume

Conversation

@ryanautomated
Copy link
Copy Markdown
Contributor

Problem

Sessions reset by /new and /resume never 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 TypeError is silently caught at DEBUG level 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 /resume get 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_key argument from both call sites, matching the already-correct expiry loop at line 1312:

File Line Change
gateway/run.py 3247 Remove session_key from /new handler
gateway/run.py 4989 Remove session_key from /resume handler
tests/gateway/test_resume_command.py 222 Update test assertion

Impact

  • Risk: Near zero. session_key was never consumed inside the flush function — it only uses session_id to load transcripts.
  • Test results: 2040 gateway tests pass, 18 flush+resume tests pass, zero regressions.
  • Pre-existing failures: 15 unrelated failures (matrix encryption, whatsapp connect, race guards) existed before this change.

Reproduction

Any /new or /resume on any platform (Telegram, Discord, CLI, etc.). The memory_flushed flag on expired sessions never gets set because the flush task crashes before running.

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
@teknium1 teknium1 merged commit 0f9aa57 into NousResearch:main Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants