fix(hindsight): implement on_session_end to flush buffered turns at session exit#16697
Closed
fayenix wants to merge 1 commit into
Closed
fix(hindsight): implement on_session_end to flush buffered turns at session exit#16697fayenix wants to merge 1 commit into
fayenix wants to merge 1 commit into
Conversation
…ession exit sync_turn() batches retention every N turns. Turns accumulated since the last batch boundary were previously lost when the session ended (gateway restart, idle timeout, /reset, /new). This left users with empty recall on the first turn after any session boundary. on_session_end now forces a final synchronous retention of any remaining buffered turns, preserving conversation context across session restarts. Fixes the Part B gap from #15165 — the plugin YAML declared the hook but the implementation was never written. Tests cover: flush of buffered turns, auto_retain skip, already-aligned no-op, zero turns, missing client, in-flight sync wait, error resilience, and session tag inclusion.
2 tasks
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.
Summary
Closes the Part B gap from #15165 ("Gateway restart drops session memory").
sync_turn()batches retention every N turns. Turns accumulated since the last batch boundary were previously lost when the session ended (gateway restart, idle timeout,/reset,/new). Theplugin.yamldeclared theon_session_endhook but the implementation was never written.What this does
Implements
on_session_end(messages)that:auto_retaindisabled or no clientaretain_batchTests
8 new tests in
TestOnSessionEndcovering: flush, auto_retain skip, aligned no-op, zero turns, missing client, in-flight sync, error resilience, session tags.All 89 existing + 8 new = 97 tests pass.
Related