-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: ABX
-
None
-
None
-
Python Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Note: this is a transcription of the GH issue langchain-mongodb/#462
Package
langchain-mongodb-deepagents-vfs
What happened?
MongoFilesystemBackend.grep() returns an empty match list both when indexed files were searched without finding relevant text and when the requested path selects no indexed files. These conditions look identical to the caller.
An application may treat an empty result as evidence that no information exists. An agent can then write an unsupported "not found" finding, and downstream steps can use that finding as if it were a verified result.
How can we reproduce it?
import os from langchain_mongodb_deepagents_vfs import MongoFilesystemBackend with MongoFilesystemBackend( s3_bucket_name=os.environ["S3_BUCKET_NAME"], # Any bucket already indexed by the VFS. mongodb_connection_string=os.environ["MONGODB_URI"], # MongoDB search index connection. ) as backend: # This arbitrary path represents any scope with no indexed files. result = backend.grep("search text", path="empty-example-scope/") print(result.error, result.matches) # Current output: None, []
Actual result: error is None and matches == [], so the missing search scope is reported as a completed search with no matching text.
What did you expect?
Expected result: when a nonempty path selects no indexed files, the existing GrepResult.error field contains an actionable path-scope message and matches is None. When the scope contains files but the query finds no text, error is None and matches == []. The Deep Agents result shape remains unchanged.
Current workaround (optional)
Check the requested scope separately before treating an empty grep result as meaningful:
files = backend.glob("**/*", path="empty-example-scope/") if not files.matches: raise ValueError("The requested search scope contains no indexed files") result = backend.grep("search text", path="empty-example-scope/")
This distinguishes an empty scope from a completed no-match search, but requires an additional query and application-side validation.
Environment
Python: Not provided
OS: Not provided
Affected packages and versions: langchain-mongodb-deepagents-vfs version not provided
MongoDB server version and deployment type: Not provided
Additional context (optional)
The VFS owns the MongoDB query and can determine whether its requested path selects any indexed source paths before reporting a normal no-match result. Using the protocol's existing error field keeps this change inside the adapter and avoids adding fields to Deep Agents' GrepResult. The strings in the example are placeholders only.