Skip to content

Conversation

@nfcampos
Copy link
Collaborator

@nfcampos nfcampos commented Oct 9, 2025

Middleware Classes

Text Editor Tools

  • StateClaudeTextEditorToolMiddleware: In-memory text editor using agent state
  • FilesystemClaudeTextEditorToolMiddleware: Text editor operating on real filesystem

Implementing Claude's text editor tools
https://docs.claude.com/en/docs/agents-and-tools/tool-use/text-editor-tool Operations: view, create, str_replace, insert

Memory Tools

  • StateClaudeMemoryToolMiddleware: Memory persistence in agent state
  • FilesystemClaudeMemoryToolMiddleware: Memory persistence on filesystem

Implementing Claude's memory tools
https://docs.claude.com/en/docs/agents-and-tools/tool-use/memory-tool Operations: Same as text editor plus delete and rename

File Search Tools

  • StateFileSearchMiddleware: Search state-based files
  • FilesystemFileSearchMiddleware: Search real filesystem

Provides Glob and Grep tools with same schema as used by Claude Code (but compatible with any model)

  • Glob: Pattern matching (e.g., /*.py, src//*.ts), sorted by modification time
  • Grep: Regex content search with output modes (files_with_matches, content, count)

Usage

StateTextEditorToolMiddleware, StateFileSearchMiddleware, )

agent = create_agent( model=model, tools=[], middleware=[
StateTextEditorToolMiddleware(), StateFileSearchMiddleware(), ], ) ```

@github-actions github-actions bot added feature langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0 labels Oct 9, 2025
@eyurtsev eyurtsev self-assigned this Oct 9, 2025
…memory, and file

search

Middleware Classes

Text Editor Tools
- StateClaudeTextEditorToolMiddleware: In-memory text editor using agent state
- FilesystemClaudeTextEditorToolMiddleware: Text editor operating on real filesystem

Implementing Claude's text editor tools
https://docs.claude.com/en/docs/agents-and-tools/tool-use/text-editor-tool Operations:
view, create, str_replace, insert

Memory Tools
- StateClaudeMemoryToolMiddleware: Memory persistence in agent state
- FilesystemClaudeMemoryToolMiddleware: Memory persistence on filesystem

Implementing Claude's memory tools
https://docs.claude.com/en/docs/agents-and-tools/tool-use/memory-tool Operations: Same
as text editor plus delete and rename

File Search Tools
- StateFileSearchMiddleware: Search state-based files
- FilesystemFileSearchMiddleware: Search real filesystem

Provides Glob and Grep tools with same schema as used by Claude Code (but compatible
with any model)
- Glob: Pattern matching (e.g., **/*.py, src/**/*.ts), sorted by modification time
- Grep: Regex content search with output modes (files_with_matches, content, count)

Usage

``` from langchain.agents import create_agent from langchain.agents.middleware import (
StateTextEditorToolMiddleware, StateFileSearchMiddleware, )

agent = create_agent( model=model, tools=[], middleware=[
StateTextEditorToolMiddleware(), StateFileSearchMiddleware(), ], ) ```
@nfcampos nfcampos force-pushed the nc/9oct/file-tools-middleware branch 3 times, most recently from 255b316 to 4d48faa Compare October 15, 2025 19:01
@nfcampos nfcampos force-pushed the nc/9oct/file-tools-middleware branch from 4d48faa to 6b6eeae Compare October 15, 2025 19:04
@eyurtsev
Copy link
Collaborator

Porting anthropic middleware in this PR: #33510 (without the non file system middleware which isn't related to anthropic)

@eyurtsev
Copy link
Collaborator

File search implemented in this PR: #33551

Closing as all middleware has been merged.

Thank you @nfcampos !

@eyurtsev eyurtsev closed this Oct 17, 2025
pokey added a commit to pokey/langchainjs that referenced this pull request Oct 24, 2025
Implements client-side Anthropic text editor, memory, and file search tools
middleware for agent workflows.

Features:
- StateClaudeTextEditorMiddleware and StateClaudeMemoryMiddleware for state-based file operations
- FilesystemClaudeTextEditorMiddleware and FilesystemClaudeMemoryMiddleware for filesystem operations
- Path validation with traversal protection and prefix enforcement
- File operations: view, create, str_replace, insert, delete, rename
- Comprehensive test coverage (79 tests total)

Ports Python implementation langchain-ai/langchain#33384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants