[PR #557] [MERGED] Implement map-reduce api for StateGraph/Pregel #1537

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraph/pull/557
Author: @nfcampos
Created: 5/30/2024
Status: Merged
Merged: 5/31/2024
Merged by: @nfcampos

Base: mainHead: nc/30may/map-reduce


📝 Commits (10+)

  • 02326d7 WIP
  • 7a2de5e WIP
  • 7a1feb4 Implement map-reduce api for StateGraph/Pregel
  • 75f14cc Finish tests
  • fb9fdcd Lint
  • b19c426 In state graph validate that all nodes either return None or write to one of the state keys
  • dc9c725 Passthrough additional keys from node to cond edge
  • 683fac8 don't clear pending packets when just viewing
  • ae9c563 Lint
  • 9fd459c Update to use a single arg like other nodes

📊 Changes

14 files changed (+1424 additions, -132 deletions)

View changed files

📝 langgraph/channels/base.py (+1 -0)
📝 langgraph/checkpoint/base.py (+7 -0)
📝 langgraph/constants.py (+10 -0)
📝 langgraph/graph/graph.py (+38 -17)
📝 langgraph/graph/state.py (+20 -8)
📝 langgraph/pregel/__init__.py (+135 -44)
📝 langgraph/pregel/io.py (+39 -18)
📝 langgraph/pregel/read.py (+6 -1)
📝 langgraph/pregel/validate.py (+5 -5)
📝 langgraph/pregel/write.py (+77 -17)
📝 langgraph/serde/jsonplus.py (+4 -1)
📝 langgraph/utils.py (+15 -15)
📝 tests/test_pregel.py (+533 -0)
📝 tests/test_pregel_async.py (+534 -6)

📄 Description

  • current Pregel primitive is pull-based, ie. nodes write to channels, and it's up to other nodes to subscribe to those channels to "pull" updates
  • this adds a "push" primitive where a node can directly schedule a node (more than once if desired) for execution in the next step, with additional kwargs to be passed in. Nodes scheduled in this way get called with both the current state and any kwargs passed to Packet

🔄 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/557 **Author:** [@nfcampos](https://github.com/nfcampos) **Created:** 5/30/2024 **Status:** ✅ Merged **Merged:** 5/31/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `nc/30may/map-reduce` --- ### 📝 Commits (10+) - [`02326d7`](https://github.com/langchain-ai/langgraph/commit/02326d74bf1d62dcfcac383a7adb55954555dcf3) WIP - [`7a2de5e`](https://github.com/langchain-ai/langgraph/commit/7a2de5e369e8c941e1521730900a82b14c281d48) WIP - [`7a1feb4`](https://github.com/langchain-ai/langgraph/commit/7a1feb466b04d04b301e89e61af487df7e4d997b) Implement map-reduce api for StateGraph/Pregel - [`75f14cc`](https://github.com/langchain-ai/langgraph/commit/75f14cc06df8f1878c88926efdaa9bfb6ab9d488) Finish tests - [`fb9fdcd`](https://github.com/langchain-ai/langgraph/commit/fb9fdcd3455e1bbf60ecab327af20c793b3a2f66) Lint - [`b19c426`](https://github.com/langchain-ai/langgraph/commit/b19c426a33f0305adf57febe243cef101eecc13a) In state graph validate that all nodes either return None or write to one of the state keys - [`dc9c725`](https://github.com/langchain-ai/langgraph/commit/dc9c7254e71865ac00687f22d4adf07c654c8734) Passthrough additional keys from node to cond edge - [`683fac8`](https://github.com/langchain-ai/langgraph/commit/683fac83dc8632e8c4462e2d1d1f2e9e161db222) don't clear pending packets when just viewing - [`ae9c563`](https://github.com/langchain-ai/langgraph/commit/ae9c5639f07f7bbde1d761260dce48bc2c89dca7) Lint - [`9fd459c`](https://github.com/langchain-ai/langgraph/commit/9fd459c7fcc9c01b6502c4a9cf12049e30a09a3f) Update to use a single arg like other nodes ### 📊 Changes **14 files changed** (+1424 additions, -132 deletions) <details> <summary>View changed files</summary> 📝 `langgraph/channels/base.py` (+1 -0) 📝 `langgraph/checkpoint/base.py` (+7 -0) 📝 `langgraph/constants.py` (+10 -0) 📝 `langgraph/graph/graph.py` (+38 -17) 📝 `langgraph/graph/state.py` (+20 -8) 📝 `langgraph/pregel/__init__.py` (+135 -44) 📝 `langgraph/pregel/io.py` (+39 -18) 📝 `langgraph/pregel/read.py` (+6 -1) 📝 `langgraph/pregel/validate.py` (+5 -5) 📝 `langgraph/pregel/write.py` (+77 -17) 📝 `langgraph/serde/jsonplus.py` (+4 -1) 📝 `langgraph/utils.py` (+15 -15) 📝 `tests/test_pregel.py` (+533 -0) 📝 `tests/test_pregel_async.py` (+534 -6) </details> ### 📄 Description - current Pregel primitive is pull-based, ie. nodes write to channels, and it's up to other nodes to subscribe to those channels to "pull" updates - this adds a "push" primitive where a node can directly schedule a node (more than once if desired) for execution in the next step, with additional kwargs to be passed in. Nodes scheduled in this way get called with both the current state and any kwargs passed to Packet --- <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:59 -05:00
yindo closed this issue 2026-02-20 17:44:59 -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#1537