[PR #186] [MERGED] fix(deepagents): grep should perform literal search instead of regex #189

Closed
opened 2026-02-16 06:17:24 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/186
Author: @christian-bromann
Created: 2/4/2026
Status: Merged
Merged: 2/4/2026
Merged by: @christian-bromann

Base: mainHead: cb/fix-grep-literal-search


📝 Commits (2)

  • de3eba7 fix(deepagents): grep should perform literal search instead of regex
  • 993bd2f Merge branch 'main' into cb/fix-grep-literal-search

📊 Changes

8 files changed (+98 additions, -91 deletions)

View changed files

📝 libs/deepagents/src/backends/composite.test.ts (+17 -14)
📝 libs/deepagents/src/backends/filesystem.test.ts (+3 -2)
📝 libs/deepagents/src/backends/filesystem.ts (+32 -25)
📝 libs/deepagents/src/backends/sandbox.test.ts (+14 -6)
📝 libs/deepagents/src/backends/sandbox.ts (+13 -18)
📝 libs/deepagents/src/backends/state.test.ts (+3 -2)
📝 libs/deepagents/src/backends/utils.ts (+13 -23)
📝 libs/deepagents/src/middleware/fs.ts (+3 -1)

📄 Description

Port of langchain-ai/deepagents#975 - Changes grep functionality from regex search to literal text search across all backends.

This is a UX improvement because:

  • Users can search for code with special characters like def __init__(, str | int, [a-z], $19.99 without escaping
  • No more "Invalid regex pattern" errors when searching for these patterns
  • More intuitive for typical code search use cases

Changes

Backend implementations:

  • filesystem.ts: Added -F flag to ripgrep for fixed-string mode, renamed pythonSearch to literalSearch using line.includes(pattern) instead of regex
  • utils.ts: Updated grepSearchFiles() and grepMatchesFromFiles() to use line.includes(pattern) instead of regex.test(line)
  • sandbox.ts: Updated buildGrepCommand() to use literal substring matching instead of regex

Documentation:

  • Updated GREP_TOOL_DESCRIPTION in middleware to clarify special characters are treated literally
  • Added example: grep(pattern="def __init__(self):")

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/186 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/4/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `cb/fix-grep-literal-search` --- ### 📝 Commits (2) - [`de3eba7`](https://github.com/langchain-ai/deepagentsjs/commit/de3eba713743cacc9ab105f170faf0b43f2f9394) fix(deepagents): grep should perform literal search instead of regex - [`993bd2f`](https://github.com/langchain-ai/deepagentsjs/commit/993bd2fb16cec1e23acebf68742d8b0833709cdd) Merge branch 'main' into cb/fix-grep-literal-search ### 📊 Changes **8 files changed** (+98 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `libs/deepagents/src/backends/composite.test.ts` (+17 -14) 📝 `libs/deepagents/src/backends/filesystem.test.ts` (+3 -2) 📝 `libs/deepagents/src/backends/filesystem.ts` (+32 -25) 📝 `libs/deepagents/src/backends/sandbox.test.ts` (+14 -6) 📝 `libs/deepagents/src/backends/sandbox.ts` (+13 -18) 📝 `libs/deepagents/src/backends/state.test.ts` (+3 -2) 📝 `libs/deepagents/src/backends/utils.ts` (+13 -23) 📝 `libs/deepagents/src/middleware/fs.ts` (+3 -1) </details> ### 📄 Description Port of langchain-ai/deepagents#975 - Changes grep functionality from regex search to literal text search across all backends. This is a UX improvement because: - Users can search for code with special characters like `def __init__(`, `str | int`, `[a-z]`, `$19.99` without escaping - No more "Invalid regex pattern" errors when searching for these patterns - More intuitive for typical code search use cases ### Changes **Backend implementations:** - `filesystem.ts`: Added `-F` flag to ripgrep for fixed-string mode, renamed `pythonSearch` to `literalSearch` using `line.includes(pattern)` instead of regex - `utils.ts`: Updated `grepSearchFiles()` and `grepMatchesFromFiles()` to use `line.includes(pattern)` instead of `regex.test(line)` - `sandbox.ts`: Updated `buildGrepCommand()` to use literal substring matching instead of regex **Documentation:** - Updated `GREP_TOOL_DESCRIPTION` in middleware to clarify special characters are treated literally - Added example: `grep(pattern="def __init__(self):")` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 06:17:24 -05:00
yindo closed this issue 2026-02-16 06:17:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#189