Skip to content

feat(aws): Enable Buffering and Flushing Writes to Checkpoint Savers#892

Open
Farouk Boukil (f4roukb) wants to merge 12 commits intolangchain-ai:mainfrom
f4roukb:feat/saver-W-buffering
Open

feat(aws): Enable Buffering and Flushing Writes to Checkpoint Savers#892
Farouk Boukil (f4roukb) wants to merge 12 commits intolangchain-ai:mainfrom
f4roukb:feat/saver-W-buffering

Conversation

@f4roukb
Copy link
Contributor

@f4roukb Farouk Boukil (f4roukb) commented Feb 21, 2026

Issue: #806

Description: Enable buffering the write ops of any checkpoint saver and flushing them manually where needed (e.g., inside the graph execution), and automatically at the end of graph execution.

Changes:

  • New BufferedCheckpointSaver class (decorator pattern with both sync and async API). It buffers writes and flushes them:
    a) After the context is exit when a context manager is used: aflush_on_exit (async) or flush_on_exit (sync).
    b) When the aflush (async) or flush (sync) method is called (potentially inside the graph).
  • Unit tests on top of Langgraph's MemorySaver, including tests for edge cases.
  • Component tests for buffering on top of AgentCoreMemorySaver, AgentCoreValkeySaver, and DynamoDBSaver.
    I essentially picked the existing component tests back up and adapted them by wrapping the instances in the buffering decorator and adapting the assertions.
    I also added more fundamental component tests in each of these test suites to ensure behavior is tested on different kinds of graphs, with streaming, with parallelism, with error mid-execution, and with flush mid-execution.
  • There is some redundancy across component tests. I tried to minimize it by adding conftest.py and utils.py files. I haven't modified the existing component tests. A clean-up could be scheduled if this PR is merged.
  • No breaking changes.

@f4roukb Farouk Boukil (f4roukb) changed the title add: saver buffering of write ops feat(langchain-aws): Enable Control over Flushing Writes from Checkpoints via Buffering Feb 21, 2026
@f4roukb Farouk Boukil (f4roukb) changed the title feat(langchain-aws): Enable Control over Flushing Writes from Checkpoints via Buffering feat(aws): Enable Control over Flushing Writes from Checkpoints via Buffering Feb 21, 2026
@f4roukb Farouk Boukil (f4roukb) changed the title feat(aws): Enable Control over Flushing Writes from Checkpoints via Buffering feat(aws): Enable Buffering and Flushing Writes to Checkpoints Feb 21, 2026
@f4roukb Farouk Boukil (f4roukb) changed the title feat(aws): Enable Buffering and Flushing Writes to Checkpoints feat(aws): Enable Buffering and Flushing Writes to Checkpointers Feb 21, 2026
@f4roukb Farouk Boukil (f4roukb) changed the title feat(aws): Enable Buffering and Flushing Writes to Checkpointers feat(aws): Enable Buffering and Flushing Writes to Checkpoint Savers Feb 21, 2026
@f4roukb
Copy link
Contributor Author

Michael Chin (@michaelnchin), since you addressed the corresponding issue, could you please have a look? Happy to address your comments. Thank you.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the submission Farouk Boukil (@f4roukb) !

Added some feedback below. Please also add additional unit/integration tests to validate these edge cases where needed.

Comment on lines 141 to 144
try:
yield self
finally:
self.flush()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if there's no danger to flushing the existing buffer on exceptions, we should still log them for visibility given that the resumed checkpoint may not behave as expected due to the ignored failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some log messages there. Let me know what you think.

@f4roukb
Copy link
Contributor Author

I missed quite a few things working on this one, huh 😅 Thanks a lot for the spot-on observations. I addressed your comments and will be working on additional unit/integration tests. Should be re-reviewable by EOW.

@f4roukb
Copy link
Contributor Author

Farouk Boukil (f4roukb) commented Mar 1, 2026

I think it's a good milestone to get some more feedback please. I updated the PR description with more details. I can add component tests for the AsyncBedrockSessionSaver afterwards. 😄

Please note that I don't have access to the necessary infrastructure to actually run and debug the component tests. I'd really appreciate it if you could help push this. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants