Repository navigation
fix(memory): capture with an evaluator marks read only the messages it judged #2836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@flow-state-dev/memory": patch | ||
| --- | ||
|
|
||
| Capture with an `evaluator` now marks read exactly the messages it judged, by id, in a new `readMessages` field on the `memorySystem` state (`MemorySystemState`). It used to move a positional watermark, so when two turns of one session overlapped, a late `skip` could mark read a turn whose evaluator call had failed, and that turn was never observed. Sessions captured before keep working: the first capture with an evaluator carries over what the watermark already covered. Without an evaluator, capture is unchanged (FIX-1555, BR-6). | ||
|
jhoffner marked this conversation as resolved.
Resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,15 @@ import type { RetrievalStrategy } from './tools/types' | |
| export const memorySystemStateSchema = z.object({ | ||
| /** Index of the last processed session item. */ | ||
| lastProcessedIndex: z.number().default(-1), | ||
| /** | ||
| * With an evaluator: the session messages a capture has judged, by item id | ||
| * and timestamp. Capture with an evaluator reads a message only while it is | ||
| * missing here, so a capture marks read exactly what it judged, however | ||
| * overlapping turns land in the log. `null` until such a capture marks | ||
| * something, and after one without an evaluator: the watermark then says | ||
| * what is read. | ||
| */ | ||
| readMessages: z.array(z.object({ id: z.string(), ts: z.number() })).nullable().default(null), | ||
|
jhoffner marked this conversation as resolved.
Resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding AGENTS.md reference: AGENTS.md:L52-L56 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this needs a re-gate, but the call belongs to the spec's owner, so I've put it to them and am leaving this thread open. FIX-1555 listed "No persisted state changes" under Decided, not asked, as an implementer note about that change set, not as an approved direction. The approved direction (D2, BR-4, BR-6: a skip is final, and an error leaves the turn unread) is unchanged, and this PR is what makes BR-6 hold when turns overlap. The positional watermark can't express "read exactly what I judged" across overlapping turns, so keeping the old shape would mean leaving BR-6 broken. Per Generated by Claude Code |
||
| /** Episodic writes since the last consolidation check. */ | ||
| episodicWritesSinceLastConsolidation: z.number().default(0), | ||
| /** Persistent/permanent entries evicted since the last consolidation. */ | ||
|
|
@@ -97,6 +106,7 @@ export const memorySystemResource = defineResource({ | |
| stateSchema: memorySystemStateSchema, | ||
| default: { | ||
| lastProcessedIndex: -1, | ||
| readMessages: null, | ||
| episodicWritesSinceLastConsolidation: 0, | ||
| evictedPersistentSinceLastConsolidation: 0, | ||
| lastConsolidationTurn: 0, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.