Claude/work mem time point on main - #545
Merged
Wang-Daoji merged 3 commits intoSep 24, 2026
Merged
Conversation
Work Memory previously only ran on a token-compaction boundary, so short Sessions that never compacted, the tail after the last compaction, and Sessions that simply went quiet produced no L1 Work Memory at all. Introduce a dedicated `work_memory_session_cursors` table plus a single `extractUnextracted(sessionId, throughTraceSeq)` entry point that three triggers now share: the compaction boundary callback, a new `work_memory_idle_flush` job armed two hours after the last completed turn, and session close (including the v2 rollover path). Each trigger schedules only the traces past the cursor, so windows are never extracted twice. Windowing reuses `splitL3TracesByRawTurn` at 20 Raw turns and never splits a turn; a further cap of 20 Q&A pairs per window truncates on a turn boundary and leaves the remainder to the next trigger. The cursor advances with the enqueue inside the caller's transaction, so a failed enqueue cannot mark a window as extracted. The generic job merge keeps the earlier `runAfter`, so the idle flush arms through a dedicated upsert that revives terminal rows and clears retry bookkeeping. L3 scheduling, episode lifecycle, hooks, and retrieval are untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ime_point-on-main
…ime_point-on-main # Conflicts: # App/backend/local-api-contracts/src/memory-runtime.ts # Memory/src/contracts/memory-runtime.ts # Memory/src/service/worker/job-handlers.ts # Memory/src/types.ts
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.
No description provided.