[PR #435] [CLOSED] feat(deepagents): add namespace factory support to StoreBackend #460

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/435
Author: @hntrl
Created: 4/7/2026
Status: Closed

Base: mainHead: hunter/namespace-factories


📝 Commits (2)

  • 08c40ce feat(deepagents): add namespace factory support to StoreBackend
  • 9dab307 chore: add changeset for namespace factory support

📊 Changes

5 files changed (+328 additions, -21 deletions)

View changed files

.changeset/namespace-factories.md (+7 -0)
📝 libs/deepagents/src/backends/index.ts (+5 -1)
📝 libs/deepagents/src/backends/store.test.ts (+226 -2)
📝 libs/deepagents/src/backends/store.ts (+89 -18)
📝 libs/deepagents/src/index.ts (+1 -0)

📄 Description

Summary

StoreBackend.namespace now accepts a NamespaceFactory function in addition to a static string[], enabling dynamic per-invocation namespace resolution. This lets users scope storage by user, assistant, thread, or any combination derived from the LangGraph Runtime — without the deprecated BackendFactory pattern.

Changes

deepagentsstore.ts

  • New NamespaceFactory type: (runtime: Partial<Runtime>) => string[]. The factory receives a Partial<Runtime> assembled from LangGraph's execution-context accessors (getConfig, getStore, getWriter) — no wrapper types, just the LangGraph Runtime directly.
  • StoreBackendOptions.namespace widened to string[] | NamespaceFactory. Static arrays are validated eagerly at construction; factories are validated at call time.
  • New StoreBackend.getRuntime() static method assembles a Partial<Runtime> from the execution context. Falls back to {} outside a graph execution (e.g. tests).
  • getNamespace() updated to call the factory on every operation when present, then validate the result through the existing namespace component rules.

deepagents — exports

  • NamespaceFactory exported from backends/index.ts and src/index.ts.

deepagentsstore.test.ts

  • 10 new tests: resolution from serverInfo.assistantId, serverInfo.user.identity, executionInfo.threadId; composite namespaces; per-invocation calling semantics; validation of factory output; multi-user isolation; graceful degradation outside execution context; runtime passthrough verification.

🔄 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/435 **Author:** [@hntrl](https://github.com/hntrl) **Created:** 4/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `hunter/namespace-factories` --- ### 📝 Commits (2) - [`08c40ce`](https://github.com/langchain-ai/deepagentsjs/commit/08c40ce09756df456fc0375e12d74d0ec0a8d66a) feat(deepagents): add namespace factory support to StoreBackend - [`9dab307`](https://github.com/langchain-ai/deepagentsjs/commit/9dab3070295e0340d63e524fd5e313ff43c1a3e7) chore: add changeset for namespace factory support ### 📊 Changes **5 files changed** (+328 additions, -21 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/namespace-factories.md` (+7 -0) 📝 `libs/deepagents/src/backends/index.ts` (+5 -1) 📝 `libs/deepagents/src/backends/store.test.ts` (+226 -2) 📝 `libs/deepagents/src/backends/store.ts` (+89 -18) 📝 `libs/deepagents/src/index.ts` (+1 -0) </details> ### 📄 Description ## Summary `StoreBackend.namespace` now accepts a `NamespaceFactory` function in addition to a static `string[]`, enabling dynamic per-invocation namespace resolution. This lets users scope storage by user, assistant, thread, or any combination derived from the LangGraph `Runtime` — without the deprecated `BackendFactory` pattern. ## Changes ### `deepagents` — `store.ts` - New `NamespaceFactory` type: `(runtime: Partial<Runtime>) => string[]`. The factory receives a `Partial<Runtime>` assembled from LangGraph's execution-context accessors (`getConfig`, `getStore`, `getWriter`) — no wrapper types, just the LangGraph `Runtime` directly. - `StoreBackendOptions.namespace` widened to `string[] | NamespaceFactory`. Static arrays are validated eagerly at construction; factories are validated at call time. - New `StoreBackend.getRuntime()` static method assembles a `Partial<Runtime>` from the execution context. Falls back to `{}` outside a graph execution (e.g. tests). - `getNamespace()` updated to call the factory on every operation when present, then validate the result through the existing namespace component rules. ### `deepagents` — exports - `NamespaceFactory` exported from `backends/index.ts` and `src/index.ts`. ### `deepagents` — `store.test.ts` - 10 new tests: resolution from `serverInfo.assistantId`, `serverInfo.user.identity`, `executionInfo.threadId`; composite namespaces; per-invocation calling semantics; validation of factory output; multi-user isolation; graceful degradation outside execution context; runtime passthrough verification. --- <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:10 -04:00
yindo closed this issue 2026-06-05 17:23:10 -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#460