[PR #1901] [MERGED] fix(langgraph): add equals method to channels for semantic comparison #1824

Closed
opened 2026-02-15 20:16:57 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/1901
Author: @dqbd
Created: 1/15/2026
Status: Merged
Merged: 1/15/2026
Merged by: @dqbd

Base: mainHead: pr/killagu/1839


📝 Commits (7)

  • ca2088d fix(langgraph): add equals method to channels for semantic comparison
  • a66c2d3 Merge branch 'main' into fix/channel-equals-comparison
  • 13b5297 Merge branch 'main' into fix/channel-equals-comparison
  • d6ae43f Merge branch 'main' into fix/channel-equals-comparison
  • 04aec84 Merge branch 'main' into fix/channel-equals-comparison
  • b528434 Add changeset
  • 74add2a Fix formatting, do equality checks right away

📊 Changes

6 files changed (+149 additions, -1 deletions)

View changed files

.changeset/common-windows-slide.md (+5 -0)
📝 libs/langgraph-core/src/channels/base.ts (+12 -0)
📝 libs/langgraph-core/src/channels/binop.ts (+17 -0)
📝 libs/langgraph-core/src/graph/state.ts (+1 -1)
📝 libs/langgraph-core/src/pregel/debug.test.ts (+2 -0)
📝 libs/langgraph-core/src/tests/zod_state.test.ts (+112 -0)

📄 Description

When using separate state/input/output schemas that share fields with
reducers (e.g., middleware stateSchema in agents), the StateGraph would
throw "Channel already exists with a different type" because it compared
channel instances by reference.

This fix adds an equals() method to BaseChannel and implements it in
BinaryOperatorAggregate to compare reducer function references, matching
the Python implementation's __eq__ behavior.

Changes:

  • Add equals() method to BaseChannel (default: reference equality)
  • Implement equals() in BinaryOperatorAggregate (compares operator refs)
  • Update _addSchema to use equals() for semantic comparison
  • Add unit tests for reducer field sharing across schemas

🔄 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/langgraphjs/pull/1901 **Author:** [@dqbd](https://github.com/dqbd) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/15/2026 **Merged by:** [@dqbd](https://github.com/dqbd) **Base:** `main` ← **Head:** `pr/killagu/1839` --- ### 📝 Commits (7) - [`ca2088d`](https://github.com/langchain-ai/langgraphjs/commit/ca2088d8111e178a2d094aebef479e5a30ebfb57) fix(langgraph): add equals method to channels for semantic comparison - [`a66c2d3`](https://github.com/langchain-ai/langgraphjs/commit/a66c2d37eb73b6b94248d805f67e021472ec9142) Merge branch 'main' into fix/channel-equals-comparison - [`13b5297`](https://github.com/langchain-ai/langgraphjs/commit/13b529772406e5131844d4a5e8d471cb3023d552) Merge branch 'main' into fix/channel-equals-comparison - [`d6ae43f`](https://github.com/langchain-ai/langgraphjs/commit/d6ae43f4705eacb3d8bb83e069fe626907cfa9be) Merge branch 'main' into fix/channel-equals-comparison - [`04aec84`](https://github.com/langchain-ai/langgraphjs/commit/04aec848116d1f56f03728fde4400f6f37923883) Merge branch 'main' into fix/channel-equals-comparison - [`b528434`](https://github.com/langchain-ai/langgraphjs/commit/b528434f7cc3b57cebf20cc3cce7c72be5790e53) Add changeset - [`74add2a`](https://github.com/langchain-ai/langgraphjs/commit/74add2aa3fa311dae98fc6e2e6f2aaef5d6f4d86) Fix formatting, do equality checks right away ### 📊 Changes **6 files changed** (+149 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/common-windows-slide.md` (+5 -0) 📝 `libs/langgraph-core/src/channels/base.ts` (+12 -0) 📝 `libs/langgraph-core/src/channels/binop.ts` (+17 -0) 📝 `libs/langgraph-core/src/graph/state.ts` (+1 -1) 📝 `libs/langgraph-core/src/pregel/debug.test.ts` (+2 -0) 📝 `libs/langgraph-core/src/tests/zod_state.test.ts` (+112 -0) </details> ### 📄 Description When using separate state/input/output schemas that share fields with reducers (e.g., middleware stateSchema in agents), the StateGraph would throw "Channel already exists with a different type" because it compared channel instances by reference. This fix adds an `equals()` method to BaseChannel and implements it in BinaryOperatorAggregate to compare reducer function references, matching the Python implementation's `__eq__` behavior. Changes: - Add `equals()` method to BaseChannel (default: reference equality) - Implement `equals()` in BinaryOperatorAggregate (compares operator refs) - Update `_addSchema` to use `equals()` for semantic comparison - Add unit tests for reducer field sharing across schemas --- <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-15 20:16:57 -05:00
yindo closed this issue 2026-02-15 20:16:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#1824