Skip to content

fix(deepagents): match CompositeBackend.glob patterns relative to the searched path - #988

Open
Mihir Inamdar (inamdarmihir) wants to merge 1 commit into
langchain-ai:mainfrom
inamdarmihir:fix/composite-glob-relative-patterns
Open

Mihir Inamdar (inamdarmihir) wants to merge 1 commit into
langchain-ai:mainfrom
inamdarmihir:fix/composite-glob-relative-patterns

Conversation

@inamdarmihir

Copy link
Copy Markdown

Fixes #887.

Problem

For a mounted route below the searched path, CompositeBackend.glob passed the caller's pattern to the mounted backend unchanged. The pattern is relative to the searched path, but the mount matches relative to its own root. With a route at /workspace/memories/:

  • glob("memories/*.txt", "/workspace") found nothing (false negative).
  • Patterns containing the mount directory with wildcards or braces (mem*/*.txt, {memories,other}/*.txt) also found nothing.

Change

New private globMount translates the pattern for each mount below the searched path:

  1. A leading ** (**/*.txt, **) passes through; it absorbs the route prefix.
  2. A pattern that spells out the mount directory has that prefix stripped (memories/*.txt becomes *.txt inside the mount).
  3. A pattern without a separator is passed through at the mount root, exactly as before.
  4. Any other pattern (mem*/*.txt, {a,b}/*.txt): list the mount with ** and match each file's path relative to the searched path with micromatch, using the options the backends use (dot: true).

Cases 1 and 2 avoid listing the whole mount. Case 4 does list it, which can be costly for a large mount.

Added a patch changeset for deepagents.

Not changed

Case 3 keeps an existing behavior: a name pattern such as *.md searched from a directory above a mount is still applied at the mount's root, so glob("*.md", "/") finds /memories/notes.md. An existing test (should work with FilesystemBackend as default and StoreBackend route) pins that. #887 calls it a false positive. I left it alone because changing it could break agents that rely on it. If you want standard glob semantics there, it is a one-line change to case 3, but it needs the test updated. I'd like a maintainer to decide.

Also not covered: when the searched path is inside a route, mounts nested inside that route are not fanned out to.

Tests

Five new tests under CompositeBackend.glob with a mount below the searched path. Four fail on the old implementation and pass now; the fifth (search path inside the mount) pins existing behavior and passes on both. libs/deepagents unit tests: 1700 passed, 1 skipped. oxlint and oxfmt --check are clean.

Related: #886 (ls, #987) is a separate PR.

Authored by Mihir

… searched path

For a mount below the searched path, glob handed the caller's pattern to
the mounted backend unchanged. The pattern is relative to the searched
path but the mount matches relative to its own root, so
glob("memories/*.txt", "/workspace") found nothing in a mount at
/workspace/memories/.

Translate the pattern: a leading ** passes through, a pattern that spells
out the mount directory has that prefix stripped, and any other pattern
containing a separator (mem*/*.txt, {a,b}/*.txt) is matched against each
file's path relative to the searched path. A pattern without a separator
still applies at the mount root, as before.

Fixes langchain-ai#887

Authored by Mihir
@changeset-bot

changeset-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a60636e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
deepagents Patch
deepagents-acp Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown

Mihir Inamdar (@inamdarmihir) is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Oct 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

deepagents-acp

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

deepagents

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

@langchain/sandbox-standard-tests

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

@langchain/daytona

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

@langchain/deno

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

@langchain/modal

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

@langchain/node-vfs

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

@langchain/quickjs

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

commit: a60636e

This branch has not been deployed

No deployments
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.

CompositeBackend.glob matches patterns in mount-local rather than caller-relative paths

1 participant