Skip to content

Invoke session finalize hooks on expiry flush#13756

Closed
dimitrovi wants to merge 1 commit into
NousResearch:mainfrom
dimitrovi:memory-automation-session-finalize
Closed

Invoke session finalize hooks on expiry flush#13756
dimitrovi wants to merge 1 commit into
NousResearch:mainfrom
dimitrovi:memory-automation-session-finalize

Conversation

@dimitrovi

Copy link
Copy Markdown

Summary

  • invoke the on_session_finalize plugin hook after successful expiry-driven memory flushes
  • pass through the expired session id and detected platform
  • keep hook failures non-fatal so expiry cleanup still completes

Why

DIM memory automation relies on session finalization side effects after idle expiry. Without this hook, Hermes flushes provider memory but does not trigger the profile-local capture path.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11205 (MemoryProvider.on_session_end never called on expiry) and #11410 (PR to fire on_session_end on expiry).

@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11205 and #11410.

@trevorgordon981

Copy link
Copy Markdown

I have tested this solution locally. The session finalize hooks now fire correctly upon expiry flush. This ensures that when sessions expire or are flushed, the appropriate cleanup hooks fire correctly, preventing resource leaks and ensuring data consistency. The fix is stable and ready for merge.\n\nTested and confirmed. ✅

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #15132 — your commit was cherry-picked onto current main with authorship preserved in git log. Added a regression test (test_idle_expiry_fires_finalize_hook) that verifies the hook fires on idle expiry, closing the coverage gap the reporter of #14981 explicitly called out.

Thanks for the clean, focused fix.

@teknium1 teknium1 closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants