Commit 3c75e41
authored
fix(langgraph): do not apply pending writes when updating state (#6389)
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 execution1 parent 575401c commit 3c75e41
File tree
3 files changed
+84
-53
lines changed- libs/langgraph
- langgraph/pregel
- tests
3 files changed
+84
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1702 | 1702 | | |
1703 | 1703 | | |
1704 | 1704 | | |
1705 | | - | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
1706 | 1708 | | |
1707 | 1709 | | |
1708 | 1710 | | |
| |||
1721 | 1723 | | |
1722 | 1724 | | |
1723 | 1725 | | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
1734 | | - | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
1739 | | - | |
1740 | | - | |
1741 | | - | |
1742 | | - | |
1743 | | - | |
1744 | | - | |
1745 | | - | |
1746 | | - | |
1747 | | - | |
1748 | | - | |
1749 | | - | |
1750 | 1726 | | |
1751 | 1727 | | |
1752 | 1728 | | |
| |||
2167 | 2143 | | |
2168 | 2144 | | |
2169 | 2145 | | |
2170 | | - | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
2171 | 2149 | | |
2172 | 2150 | | |
2173 | 2151 | | |
| |||
2186 | 2164 | | |
2187 | 2165 | | |
2188 | 2166 | | |
2189 | | - | |
2190 | | - | |
2191 | | - | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | | - | |
2197 | | - | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
2204 | | - | |
2205 | | - | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
2209 | | - | |
2210 | | - | |
2211 | | - | |
2212 | | - | |
2213 | | - | |
2214 | 2167 | | |
2215 | 2168 | | |
2216 | 2169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8805 | 8805 | | |
8806 | 8806 | | |
8807 | 8807 | | |
| 8808 | + | |
| 8809 | + | |
| 8810 | + | |
| 8811 | + | |
| 8812 | + | |
| 8813 | + | |
| 8814 | + | |
| 8815 | + | |
| 8816 | + | |
| 8817 | + | |
| 8818 | + | |
| 8819 | + | |
| 8820 | + | |
| 8821 | + | |
| 8822 | + | |
| 8823 | + | |
| 8824 | + | |
| 8825 | + | |
| 8826 | + | |
| 8827 | + | |
| 8828 | + | |
| 8829 | + | |
| 8830 | + | |
| 8831 | + | |
| 8832 | + | |
| 8833 | + | |
| 8834 | + | |
| 8835 | + | |
| 8836 | + | |
| 8837 | + | |
| 8838 | + | |
| 8839 | + | |
| 8840 | + | |
| 8841 | + | |
| 8842 | + | |
| 8843 | + | |
| 8844 | + | |
| 8845 | + | |
| 8846 | + | |
| 8847 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9249 | 9249 | | |
9250 | 9250 | | |
9251 | 9251 | | |
| 9252 | + | |
| 9253 | + | |
| 9254 | + | |
| 9255 | + | |
| 9256 | + | |
| 9257 | + | |
| 9258 | + | |
| 9259 | + | |
| 9260 | + | |
| 9261 | + | |
| 9262 | + | |
| 9263 | + | |
| 9264 | + | |
| 9265 | + | |
| 9266 | + | |
| 9267 | + | |
| 9268 | + | |
| 9269 | + | |
| 9270 | + | |
| 9271 | + | |
| 9272 | + | |
| 9273 | + | |
| 9274 | + | |
| 9275 | + | |
| 9276 | + | |
| 9277 | + | |
| 9278 | + | |
| 9279 | + | |
| 9280 | + | |
| 9281 | + | |
| 9282 | + | |
| 9283 | + | |
| 9284 | + | |
| 9285 | + | |
| 9286 | + | |
| 9287 | + | |
| 9288 | + | |
| 9289 | + | |
0 commit comments