[PR #510] [MERGED] Merge configurable fields with previous checkpoint config before each run #1509

Closed
opened 2026-02-20 17:44:55 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/510
Author: @andrewnguonly
Created: 5/20/2024
Status: Merged
Merged: 5/21/2024
Merged by: @andrewnguonly

Base: mainHead: update-checkpoint-config


📝 Commits (3)

  • d33cb94 Merge configurable fields with previous checkpoint config.
  • d5a85d1 Update update_state() and aupdate_state() to merge configurable fields with previous checkpoint config.
  • 80efd5c Update tests to verify that all checkpoint metadata contain the expected configurable field keys. This assertion is needed because a run can have an arbitrary number of steps based on the construction of the graph.

📊 Changes

4 files changed (+433 additions, -6 deletions)

View changed files

📝 langgraph/pregel/__init__.py (+46 -4)
📝 tests/memory_assert.py (+63 -0)
📝 tests/test_pregel.py (+162 -1)
📝 tests/test_pregel_async.py (+162 -1)

📄 Description

Summary

The following scenario occurs in OpenGPTs/LangChain API, which is what prompted this change.

  1. Thread run is posted and graph execution is interrupted before tool execution.
  2. Inspecting the thread's checkpoint metadata shows that graph_id and assistant_id are present in the checkpoint metadata. This is correct an expected.
  3. Resume graph execution (i.e. post another thread run with null input).
  4. Inspecting the thread's checkpoint metadata shows that graph_id and assistant_id are NOT present in the checkpoint metadata. This is unexpected.

The solution/feature to accommodate this scenario is to merge a run's configurable fields with the previous checkpoint config (if any). This ensures that when a graph resumes execution from an interrupt, it should contain the configurable fields from the current run. This assumes that a client continues to send the same configurable fields across each run.

Implementation.

  1. Update Pregel stream(), astream(), update_state(), and aupdate_state() to merge configurable fields with previous checkpoint config.

To Do

  • Double check that update_state() and aupdate_state() are supposed to be updated.
  • Maybe refactor the code to deduplicate the repeated code.

Notes

  1. This PR blocks https://github.com/langchain-ai/opengpts/pull/341.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraph/pull/510 **Author:** [@andrewnguonly](https://github.com/andrewnguonly) **Created:** 5/20/2024 **Status:** ✅ Merged **Merged:** 5/21/2024 **Merged by:** [@andrewnguonly](https://github.com/andrewnguonly) **Base:** `main` ← **Head:** `update-checkpoint-config` --- ### 📝 Commits (3) - [`d33cb94`](https://github.com/langchain-ai/langgraph/commit/d33cb940f2bb5c541d817a9917e713692fc4e6ac) Merge configurable fields with previous checkpoint config. - [`d5a85d1`](https://github.com/langchain-ai/langgraph/commit/d5a85d14febd9c10cb3c45f4de34c5c51b5199a1) Update update_state() and aupdate_state() to merge configurable fields with previous checkpoint config. - [`80efd5c`](https://github.com/langchain-ai/langgraph/commit/80efd5ce7a9e4e8e2110dbb89e81b4307a76d13f) Update tests to verify that all checkpoint metadata contain the expected configurable field keys. This assertion is needed because a run can have an arbitrary number of steps based on the construction of the graph. ### 📊 Changes **4 files changed** (+433 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `langgraph/pregel/__init__.py` (+46 -4) 📝 `tests/memory_assert.py` (+63 -0) 📝 `tests/test_pregel.py` (+162 -1) 📝 `tests/test_pregel_async.py` (+162 -1) </details> ### 📄 Description ### Summary The following scenario occurs in OpenGPTs/LangChain API, which is what prompted this change. 1. Thread run is posted and graph execution is interrupted before tool execution. 2. Inspecting the thread's checkpoint metadata shows that `graph_id` and `assistant_id` are present in the checkpoint metadata. This is correct an expected. 3. Resume graph execution (i.e. post another thread run with null input). 4. Inspecting the thread's checkpoint metadata shows that `graph_id` and `assistant_id` are NOT present in the checkpoint metadata. This is unexpected. The solution/feature to accommodate this scenario is to merge a run's configurable fields with the previous checkpoint config (if any). This ensures that when a graph resumes execution from an interrupt, it should contain the configurable fields from the current run. This assumes that a client continues to send the same configurable fields across each run. ### Implementation. 1. Update `Pregel` `stream()`, `astream()`, `update_state()`, and `aupdate_state()` to merge configurable fields with previous checkpoint config. ### To Do - [x] Double check that `update_state()` and `aupdate_state()` are supposed to be updated. - [x] ~~Maybe refactor the code to deduplicate the repeated code.~~ ### Notes 1. This PR blocks https://github.com/langchain-ai/opengpts/pull/341. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-20 17:44:55 -05:00
yindo closed this issue 2026-02-20 17:44:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#1509