[PR #419] [MERGED] fix: deprecate backend factories #443

Closed
opened 2026-06-05 17:23:06 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/419
Author: @colifran
Created: 4/2/2026
Status: Merged
Merged: 4/2/2026
Merged by: @colifran

Base: mainHead: colifran/backend-factories


📝 Commits (9)

📊 Changes

10 files changed (+520 additions, -218 deletions)

View changed files

.changeset/few-sails-tie.md (+5 -0)
📝 examples/backends/composite-backend.ts (+3 -4)
📝 examples/backends/state-backend.ts (+1 -1)
📝 examples/backends/store-backend.ts (+1 -1)
📝 libs/deepagents/src/backends/protocol.ts (+12 -0)
📝 libs/deepagents/src/backends/state.test.ts (+119 -1)
📝 libs/deepagents/src/backends/state.ts (+95 -6)
📝 libs/deepagents/src/backends/store.test.ts (+132 -1)
📝 libs/deepagents/src/backends/store.ts (+61 -19)
📝 pnpm-lock.yaml (+91 -185)

📄 Description

Port of https://github.com/langchain-ai/deepagents/pull/2360

Before: Every tool call assembled { state, store } from the current LangGraph context and passed it into a factory function to construct fresh backends. StateBackend read files from the state argument and returned filesUpdate in write/edit results for the middleware to wrap in a Command and apply as a state update. StoreBackend extracted the store from the same argument to make store calls.

After: Both backends are constructed once at agent creation time with no arguments. When their methods are called during tool execution, StateBackend reads current state via getCurrentTaskInput() and pushes state updates directly via __pregel_send, while StoreBackend retrieves the store via getStore(). The filesUpdate value and middleware's Command wrapping are still present for the legacy StateBackend path but no longer needed for the new zero-arg constructor path.

The factory pattern remains the default and continues to work which gives users the option to pass pre-constructed instances instead.


🔄 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/deepagentsjs/pull/419 **Author:** [@colifran](https://github.com/colifran) **Created:** 4/2/2026 **Status:** ✅ Merged **Merged:** 4/2/2026 **Merged by:** [@colifran](https://github.com/colifran) **Base:** `main` ← **Head:** `colifran/backend-factories` --- ### 📝 Commits (9) - [`ad4d38c`](https://github.com/langchain-ai/deepagentsjs/commit/ad4d38c27202f788471dd38ee4a8c917840f9ff2) add zero-arg constructor to StateBackend - [`d2b9fd7`](https://github.com/langchain-ai/deepagentsjs/commit/d2b9fd734a7de859e378cf0ea365459a2d33aa3b) add zero-arg constructor to StoreBackend - [`d151c50`](https://github.com/langchain-ai/deepagentsjs/commit/d151c50b547ba9a8f4b308bb2a7648c64d7b76c2) updates tests, examples, docstrings - [`3562ab7`](https://github.com/langchain-ai/deepagentsjs/commit/3562ab73ae5e8aa8590cae12283d824eb889d95f) tests - [`6da4182`](https://github.com/langchain-ai/deepagentsjs/commit/6da4182386f93b7b4a9ef16e93ba625060cc8c68) Merge branch 'main' into colifran/backend-factories - [`1c3629b`](https://github.com/langchain-ai/deepagentsjs/commit/1c3629bbeec04131d5075850d42f472986254c8c) changeset - [`c51dac8`](https://github.com/langchain-ai/deepagentsjs/commit/c51dac8131ddbace0fe90c3a154288be81e6e5c3) lint - [`a995a22`](https://github.com/langchain-ai/deepagentsjs/commit/a995a22f7ad30341f9efa33ddfe9c5487d808532) lockfile - [`48801d6`](https://github.com/langchain-ai/deepagentsjs/commit/48801d66978f1e278b6461bf3b7508245b3b16ba) clean up ### 📊 Changes **10 files changed** (+520 additions, -218 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/few-sails-tie.md` (+5 -0) 📝 `examples/backends/composite-backend.ts` (+3 -4) 📝 `examples/backends/state-backend.ts` (+1 -1) 📝 `examples/backends/store-backend.ts` (+1 -1) 📝 `libs/deepagents/src/backends/protocol.ts` (+12 -0) 📝 `libs/deepagents/src/backends/state.test.ts` (+119 -1) 📝 `libs/deepagents/src/backends/state.ts` (+95 -6) 📝 `libs/deepagents/src/backends/store.test.ts` (+132 -1) 📝 `libs/deepagents/src/backends/store.ts` (+61 -19) 📝 `pnpm-lock.yaml` (+91 -185) </details> ### 📄 Description Port of https://github.com/langchain-ai/deepagents/pull/2360 Before: Every tool call assembled { state, store } from the current LangGraph context and passed it into a factory function to construct fresh backends. StateBackend read files from the state argument and returned filesUpdate in write/edit results for the middleware to wrap in a Command and apply as a state update. StoreBackend extracted the store from the same argument to make store calls. After: Both backends are constructed once at agent creation time with no arguments. When their methods are called during tool execution, StateBackend reads current state via getCurrentTaskInput() and pushes state updates directly via __pregel_send, while StoreBackend retrieves the store via getStore(). The filesUpdate value and middleware's Command wrapping are still present for the legacy StateBackend path but no longer needed for the new zero-arg constructor path. The factory pattern remains the default and continues to work which gives users the option to pass pre-constructed instances instead. --- <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-06-05 17:23:06 -04:00
yindo closed this issue 2026-06-05 17:23:06 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#443