[PR #402] [CLOSED] fix(sdk): deprecate backend factories #427

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/402
Author: @colifran
Created: 4/1/2026
Status: Closed

Base: alphaHead: colifran/deprecate-backend-factories


📝 Commits (10+)

  • 6642c7e support zero-arg constructors for StateBackend and StoreBackend
  • f049f19 remove unused import
  • cd480d7 format
  • 3f45cbf default to zero-arg StateBackend in middleware and agent
  • 7fff4c5 update examples with zero-args state and store backend constructors
  • 8e89115 fix tests
  • 1704269 adjust deprecation message
  • 84dc3c0 Merge branch 'alpha' into colifran/deprecate-backend-factories
  • 5119304 spelling
  • e5986d2 linting

📊 Changes

10 files changed (+743 additions, -35 deletions)

View changed files

.changeset/lazy-bears-strive.md (+5 -0)
📝 examples/backends/composite-backend.ts (+3 -4)
📝 examples/backends/state-backend.ts (+1 -1)
📝 libs/deepagents/src/backends/composite.test.ts (+212 -2)
📝 libs/deepagents/src/backends/protocol.ts (+20 -0)
📝 libs/deepagents/src/backends/state.test.ts (+174 -3)
📝 libs/deepagents/src/backends/state.ts (+90 -11)
📝 libs/deepagents/src/backends/store.test.ts (+174 -1)
📝 libs/deepagents/src/backends/store.ts (+63 -12)
📝 libs/deepagents/src/middleware/fs.ts (+1 -1)

📄 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.


🔄 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/402 **Author:** [@colifran](https://github.com/colifran) **Created:** 4/1/2026 **Status:** ❌ Closed **Base:** `alpha` ← **Head:** `colifran/deprecate-backend-factories` --- ### 📝 Commits (10+) - [`6642c7e`](https://github.com/langchain-ai/deepagentsjs/commit/6642c7e4a849a232adbcf52a8ba02ace472183ff) support zero-arg constructors for StateBackend and StoreBackend - [`f049f19`](https://github.com/langchain-ai/deepagentsjs/commit/f049f19e7d460e77732e7292361bb0ec412185e7) remove unused import - [`cd480d7`](https://github.com/langchain-ai/deepagentsjs/commit/cd480d7858be55e95e444f145d05ce89621c7dc7) format - [`3f45cbf`](https://github.com/langchain-ai/deepagentsjs/commit/3f45cbffcac37a3e11b77e1cd63dd1c2e0f20a40) default to zero-arg StateBackend in middleware and agent - [`7fff4c5`](https://github.com/langchain-ai/deepagentsjs/commit/7fff4c5f414ac1614e5db5a995b27ff87995832d) update examples with zero-args state and store backend constructors - [`8e89115`](https://github.com/langchain-ai/deepagentsjs/commit/8e891150e0342225f0edc68d119bcc6cb2f639b0) fix tests - [`1704269`](https://github.com/langchain-ai/deepagentsjs/commit/17042695b2292242cb896d10c876bfec2c7336c6) adjust deprecation message - [`84dc3c0`](https://github.com/langchain-ai/deepagentsjs/commit/84dc3c0e65d3cd017f4dde7281618bbfb119a269) Merge branch 'alpha' into colifran/deprecate-backend-factories - [`5119304`](https://github.com/langchain-ai/deepagentsjs/commit/5119304298aa2fc74e8ea7d0bfa96b6bac889ca5) spelling - [`e5986d2`](https://github.com/langchain-ai/deepagentsjs/commit/e5986d273675ef6ff455a18f92cd0a637421cdb3) linting ### 📊 Changes **10 files changed** (+743 additions, -35 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/lazy-bears-strive.md` (+5 -0) 📝 `examples/backends/composite-backend.ts` (+3 -4) 📝 `examples/backends/state-backend.ts` (+1 -1) 📝 `libs/deepagents/src/backends/composite.test.ts` (+212 -2) 📝 `libs/deepagents/src/backends/protocol.ts` (+20 -0) 📝 `libs/deepagents/src/backends/state.test.ts` (+174 -3) 📝 `libs/deepagents/src/backends/state.ts` (+90 -11) 📝 `libs/deepagents/src/backends/store.test.ts` (+174 -1) 📝 `libs/deepagents/src/backends/store.ts` (+63 -12) 📝 `libs/deepagents/src/middleware/fs.ts` (+1 -1) </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. --- <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:02 -04:00
yindo closed this issue 2026-06-05 17:23:02 -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#427