MemorySaver ignores newVersions argument on put - not storing deltas #113

Closed
opened 2026-02-15 17:15:55 -05:00 by yindo · 5 comments
Owner

Originally created by @benjamincburns on GitHub (Oct 14, 2024).

Found while working on #541. Per discussion on #577, MemorySaver isn't respecting the newVersions argument, and as a result it's storing the entire contents of checkpoint.channel_values on every call.

Originally created by @benjamincburns on GitHub (Oct 14, 2024). Found while working on #541. Per discussion on #577, `MemorySaver` isn't respecting the `newVersions` argument, and as a result it's storing the entire contents of `checkpoint.channel_values` on every call.
yindo closed this issue 2026-02-15 17:15:55 -05:00
Author
Owner

@trollboss2572 commented on GitHub (Oct 27, 2024):

Good morning, we are a group of students at the University of Toronto currently investigating the issue mentioned and believe that we could help tackle this. Can we get this opened as an issue and assigned to me? @jacoblee93

@trollboss2572 commented on GitHub (Oct 27, 2024): Good morning, we are a group of students at the University of Toronto currently investigating the issue mentioned and believe that we could help tackle this. Can we get this opened as an issue and assigned to me? @jacoblee93
Author
Owner

@benjamincburns commented on GitHub (Oct 29, 2024):

@trollboss2572 I discussed this briefly with @nfcampos the other day, and I think there's an open question as to whether or not this is a valid issue.

The newVersions argument on put can be optionally used by checkpointers to determine which channels have updated state since the previous checkpoint. This allows storage backends to avoid storing duplicate state for channels that haven't changed since the previous checkpoint. In the case of MemorySaver, there's a valid argument that this isn't a worthwhile optimization.

In my opinion, whether or not this is an issue boils down to whether the LangGraph team wants MemorySaver to serve as a reference implementation for checkpointer authors to follow. If so, then it would make sense to implement versioned channel storage, as otherwise MemorySaver would be an incomplete reference.

Furthermore, if the LangGraph team decide that MemorySaver should stay as-is, then the test in @langchain/langgraph-checkpoint-validation that validates versioned channel storage should either be removed, or more ideally, moved to an "optional" suite that only runs when the user explicitly requests tests for optimizations.

@benjamincburns commented on GitHub (Oct 29, 2024): @trollboss2572 I discussed this briefly with @nfcampos the other day, and I think there's an open question as to whether or not this is a valid issue. The `newVersions` argument on `put` can be optionally used by checkpointers to determine which channels have updated state since the previous checkpoint. This allows storage backends to avoid storing duplicate state for channels that haven't changed since the previous checkpoint. In the case of `MemorySaver`, there's a valid argument that this isn't a worthwhile optimization. In my opinion, whether or not this is an issue boils down to whether the LangGraph team wants `MemorySaver` to serve as a reference implementation for checkpointer authors to follow. If so, then it would make sense to implement versioned channel storage, as otherwise `MemorySaver` would be an incomplete reference. Furthermore, if the LangGraph team decide that `MemorySaver` should stay as-is, then [the test in `@langchain/langgraph-checkpoint-validation` that validates versioned channel storage](https://github.com/langchain-ai/langgraphjs/blob/883fbf7974ef69f32266dbbde51040130a6adbc6/libs/checkpoint-validation/src/spec/put.ts#L204-L256) should either be removed, or more ideally, moved to an "optional" suite that only runs when the user explicitly requests tests for optimizations.
Author
Owner

@trollboss2572 commented on GitHub (Oct 29, 2024):

@benjamincburns Thank you for the swift response to my message.

While I was researching the codebase I came to the same conclusion. This is more of an architectural issue than an implementation issue/feature/bug, so I believe this would be above my pay grade and would be more suited to the maintainers of langgraph to see what option they would prefer, as you mentioned.

I read your other post and saw your recommendations for implementing CheckpointSaver for a different database framework, I believe that might be the best bet if we were to implement something. Thank you for your advice on that.

Thank you for your time and for being open to questions should they arise. If there is anything that can be done by volunteers regarding the architectural updates to MemorySaver though, let me know.

@trollboss2572 commented on GitHub (Oct 29, 2024): @benjamincburns Thank you for the swift response to my message. While I was researching the codebase I came to the same conclusion. This is more of an architectural issue than an implementation issue/feature/bug, so I believe this would be above my pay grade and would be more suited to the maintainers of langgraph to see what option they would prefer, as you mentioned. I read your other post and saw your recommendations for implementing CheckpointSaver for a different database framework, I believe that might be the best bet if we were to implement something. Thank you for your advice on that. Thank you for your time and for being open to questions should they arise. If there is anything that can be done by volunteers regarding the architectural updates to MemorySaver though, let me know.
Author
Owner

@benjamincburns commented on GitHub (Oct 29, 2024):

@trollboss2572 no worries, happy to help. Though just a reminder, I'm a volunteer just like you, so your guess is roughly as good as mine :-)

@benjamincburns commented on GitHub (Oct 29, 2024): @trollboss2572 no worries, happy to help. Though just a reminder, I'm a volunteer just like you, so your guess is roughly as good as mine :-)
Author
Owner

@benjamincburns commented on GitHub (Jan 14, 2025):

Closing this, as from discussion with @nfcampos back in October, it doesn't make sense to worry about state deltas in MemorySaver.

@benjamincburns commented on GitHub (Jan 14, 2025): Closing this, as from discussion with @nfcampos back in October, it doesn't make sense to worry about state deltas in `MemorySaver`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#113