Skip to content

Conversation

@eyurtsev
Copy link
Collaborator

@eyurtsev eyurtsev commented Oct 16, 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

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 integration Related to a provider partner package integration langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0 feature labels Oct 16, 2025
@github-actions github-actions bot added feature and removed feature labels Oct 16, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 16, 2025

CodSpeed Performance Report

Merging #33510 will not alter performance

Comparing eugene/anthropic-middleware-more (2381e02) with master (5489df7)1

Summary

✅ 3 untouched
⏩ 31 skipped2

Footnotes

  1. No successful run was found on master (90b6805) during the generation of this report, so 5489df7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 31 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@eyurtsev
Copy link
Collaborator Author

This PR is porting the middleware implementations here: #33384 into the langchain_anthropic package with the exception of the file system middleware which is doesn't dependent on anthropic

@eyurtsev eyurtsev marked this pull request as ready for review October 16, 2025 01:35
@eyurtsev eyurtsev requested review from ccurme and mdrxy as code owners October 16, 2025 01:35
@eyurtsev
Copy link
Collaborator Author

Depends on this PR: #33512

nfcampos and others added 13 commits October 16, 2025 17:20
…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(), ], ) ```
@eyurtsev eyurtsev force-pushed the eugene/anthropic-middleware-more branch from 9acba40 to cdcb5bb Compare October 16, 2025 22:03
@eyurtsev eyurtsev merged commit 34de8ec into master Oct 17, 2025
44 checks passed
@eyurtsev eyurtsev deleted the eugene/anthropic-middleware-more branch October 17, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature integration Related to a provider partner package integration 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.

3 participants