[PR #6389] fix(langgraph): do not apply pending writes when updating state #5008

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

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6389

State: closed
Merged: Yes


PR #6195 fixed bulk_update_state to populate task.result by calling prepare_next_tasks to discover task IDs. Before #6195, prepare_next_tasks was gated by the condition CONFIG_KEY_CHECKPOINT_ID not in config[CONF] - so it only ran if we were resuming from an empty checkpoint. This check was removed in order to properly populate task results. However, the removal of this check inadvertently applied pending writes during manual state updates which caused issues when forking:

  • When you fork from a checkpoint by calling update_state(config, new_values, as_node="mynode"), pending writes from the original execution were being applied
  • This caused stale data to leak into forked threads (eg. old tool call results appearing in forked execution)

Changes

Removed pending writes application from bulk_update_state and abulk_update_state:

  • Still call prepare_next_tasks to discover task IDs, but skip the code that applies null writes and regular pending writes

Tests

  • Added test_fork_does_not_apply_pending_writes for sync and async which verifies forking doesn't include stale pending writes from original execution
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6389 **State:** closed **Merged:** Yes --- PR #6195 fixed `bulk_update_state` to populate `task.result` by calling `prepare_next_tasks` to discover task IDs. Before #6195, prepare_next_tasks was gated by the condition `CONFIG_KEY_CHECKPOINT_ID not in config[CONF]` - so it only ran if we were resuming from an empty checkpoint. This check was removed in order to properly populate task results. However, the removal of this check inadvertently applied pending writes during manual state updates which caused issues when forking: - When you fork from a checkpoint by calling `update_state(config, new_values, as_node="mynode")`, pending writes from the original execution were being applied - This caused stale data to leak into forked threads (eg. old tool call results appearing in forked execution) Changes Removed pending writes application from `bulk_update_state` and `abulk_update_state`: - Still call `prepare_next_tasks` to discover task IDs, but skip the code that applies null writes and regular pending writes Tests - Added `test_fork_does_not_apply_pending_writes` for sync and async which verifies forking doesn't include stale pending writes from original execution
yindo added the pull-request label 2026-02-20 17:51:05 -05:00
yindo closed this issue 2026-02-20 17:51:05 -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#5008