Skip to content

fix(deepagents): scope StoreBackend ls/glob/grep to exact namespace (#772) - #796

Open
Nihar Ranjan Hota (Nihar1420) wants to merge 2 commits into
langchain-ai:mainfrom
Nihar1420:fix/store-namespace-isolation
Open

fix(deepagents): scope StoreBackend ls/glob/grep to exact namespace (#772)#796
Nihar Ranjan Hota (Nihar1420) wants to merge 2 commits into
langchain-ai:mainfrom
Nihar1420:fix/store-namespace-isolation

Conversation

@Nihar1420

Copy link
Copy Markdown

Summary

StoreBackend is pinned to a single namespace, but its listing operations (ls, glob, grep) query the underlying store with store.search(namespace), which matches by namespace prefix. Sibling namespaces that share a leading string — e.g. ["tenant","acme"] and ["tenant","acme-corp"] — leak into each other: one backend's ls/glob/grep returns (and grep prints the line contents of) the other's files, even though read/write correctly use exact get/put.

Fixes #772.

Root cause

searchStorePaginated() accumulates every item returned by store.search(namespace). Because that search is a prefix match, items from sibling namespaces are included. read / readRaw / write go through get / put, which match the namespace exactly — which is why the same backend will list and grep a file that it then refuses to read.

Fix

Filter the paginated search results down to items whose namespace is exactly the backend's namespace, via a small namespacesEqual helper. A StoreBackend never nests files into sub-namespaces (the file path lives in the item key), so exact-namespace matching is the correct invariant. This repairs ls, glob, and grep in one place, since all three build their file set from searchStorePaginated.

Test

Added a regression test (StoreBackend namespace isolation) that mounts two sibling-prefix backends on one store and asserts ls / glob / grep each see only their own namespace, while the sibling still sees its own file.

Copilot AI lite review requested due to automatic review settings August 27, 2026 15:38
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

harikeshdev76-ux is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 04efdb0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a namespace-isolation bug in StoreBackend where ls/glob/grep could return (and grep could expose) files from sibling namespaces that share a string prefix, by filtering paginated store.search() results down to items in the backend’s exact namespace. It also adds a regression test to validate isolation between sibling namespaces (e.g. ["tenant","acme"] vs ["tenant","acme-corp"]).

Changes:

  • Added an exact-namespace equality helper and used it to filter results accumulated by searchStorePaginated().
  • Ensured ls/glob/grep (and any other callers of searchStorePaginated) only operate on items in the backend’s exact namespace.
  • Added a regression test covering sibling-prefix namespaces to prevent future leakage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
libs/deepagents/src/backends/store.ts Filters store.search() pagination results to items whose namespace exactly matches the backend namespace to prevent sibling-prefix leakage.
libs/deepagents/src/backends/store.test.ts Adds a regression test to confirm ls/glob/grep don’t leak results across sibling namespaces with shared prefixes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +189 to +193
/**
* Deep-equality check for two store namespaces.
*/
function namespacesEqual(a: string[] | undefined, b: string[]): boolean {
if (!a || a.length !== b.length) return false;
Comment on lines +1071 to +1073
describe("StoreBackend namespace isolation", () => {
it("ls/glob/grep only see the backend's exact namespace, not sibling prefixes (#772)", async () => {
const { runtime } = makeConfig();
@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

deepagents-acp

npm i https://pkg.pr.new/deepagents-acp@796

deepagents

npm i https://pkg.pr.new/deepagents@796

@langchain/sandbox-standard-tests

npm i https://pkg.pr.new/@langchain/sandbox-standard-tests@796

@langchain/daytona

npm i https://pkg.pr.new/@langchain/daytona@796

@langchain/deno

npm i https://pkg.pr.new/@langchain/deno@796

@langchain/modal

npm i https://pkg.pr.new/@langchain/modal@796

@langchain/node-vfs

npm i https://pkg.pr.new/@langchain/node-vfs@796

@langchain/quickjs

npm i https://pkg.pr.new/@langchain/quickjs@796

commit: 04efdb0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StoreBackend ls/glob/grep return files from sibling namespaces that share a string prefix, while read correctly does not

3 participants