Repository navigation
fix(deepagents): match CompositeBackend.glob patterns relative to the searched path - #988
Open
Mihir Inamdar (inamdarmihir) wants to merge 1 commit into
Conversation
… 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 detectedLatest commit: a60636e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
|
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. |
deepagents-acp
deepagents
@langchain/sandbox-standard-tests
@langchain/daytona
@langchain/deno
@langchain/modal
@langchain/node-vfs
@langchain/quickjs
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #887.
Problem
For a mounted route below the searched path,
CompositeBackend.globpassed 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).mem*/*.txt,{memories,other}/*.txt) also found nothing.Change
New private
globMounttranslates the pattern for each mount below the searched path:**(**/*.txt,**) passes through; it absorbs the route prefix.memories/*.txtbecomes*.txtinside the mount).mem*/*.txt,{a,b}/*.txt): list the mount with**and match each file's path relative to the searched path withmicromatch, 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
*.mdsearched from a directory above a mount is still applied at the mount's root, soglob("*.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/deepagentsunit tests: 1700 passed, 1 skipped.oxlintandoxfmt --checkare clean.Related: #886 (
ls, #987) is a separate PR.Authored by Mihir