-
Notifications
You must be signed in to change notification settings - Fork 19.5k
feat(anthropic): add more anthropic middleware #33510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CodSpeed Performance ReportMerging #33510 will not alter performanceComparing Summary
Footnotes
|
|
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 |
|
Depends on this PR: #33512 |
…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(), ], ) ```
9acba40 to
cdcb5bb
Compare
Middleware Classes
Text Editor Tools
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
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
Provides Glob and Grep tools with same schema as used by Claude Code (but compatible with any model)
Usage