-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
Affects Version/s: langchain-mongodb-deepagents-vfs-0.1.0
-
Component/s: ABX
-
None
-
None
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Review PR #460 from langchain dev: "fix(deepagents-vfs): strip leading slash in grep/ls/glob so agent paths match".
Reported problem
When MongoFilesystemBackend is used as a Deep Agent backend, grep/ls/glob return empty even when the files exist, so the agent reports the corpus is empty. Deep Agents' file tools pass absolute paths (e.g. /mongodb_vfs/journal), but SearchRouter builds a ^<path> regex against source_path, where stored keys are relative (no leading slash) — so the regex never matches.
Proposed change
All in SearchRouter (search.py):
- ls(): path.rstrip("/") -> path.strip("/")
- _glob(): path.rstrip("/") -> path.strip("/")
- grep(): path.lstrip("/") before the value is used as a ^<path> regex prefix
The author notes this matches existing behavior elsewhere: glob() already does pattern.lstrip("/") and the S3 backend's _key() does .lstrip("/").
Tests
Adds TestSearchRouterLeadingSlash (unit, mongomock — no Atlas) asserting ls/glob/grep return the same non-empty results for /docs as for docs. Reported 19 passed.
Task
Review correctness and test coverage, confirm path normalization is the right fix, and decide on changelog entry and merge.