-
Notifications
You must be signed in to change notification settings - Fork 19.3k
feat(langchain): add deepagents middleware and prebuilt #33405
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
base: nc/9oct/file-tools-middleware
Are you sure you want to change the base?
Conversation
…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(), ], ) ```
…nto nh/subagent-middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very quick drive by comments --- no need to address right now, i'll take another look in the morning tomorrow
libs/langchain_v1/tests/integration_tests/agents/middleware/test_subagent_middleware.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deepagents are super exciting! Really looking forward to these new middlewares, especially the subagents one.
I have some concern about introducing the create_deep_agent
factory here, imo it has a significantly lower ceiling than create_agent
because under the hood, we decide on all of the middleware being used. That means we decide on the config, prompts, etc. And it's not easy to plug and play w/ the current API.
When on a call w/ a customer using deepagents recently, they mentioned they really liked the deepagent middleware, but they were going to have to copy all of the deepagents code and then make their own customizations to the middleware stack (ex, different settings for summarization, etc).
I would be more comfortable if we introduced just the middleware for now + really leaned into documenting how to create a "deep agent" (it's really just a few lines of code right, basically the list of middleware + the base agent prompt).
We could have a whole deepagents guide or even conceptual page that talks about all the ways you might want to customize your deep agent :)
def wrap_model_call( | ||
self, | ||
request: ModelRequest, | ||
handler: Callable[[ModelRequest], AIMessage], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to myself we should have a type alias here, I can work on this over the weekend :)
Another note -- I've updated the HITL API as discussed, will want to update this accordingly. |
255b316
to
4d48faa
Compare
4d48faa
to
6b6eeae
Compare
task
tool which allows the main agent to create subagentsTODO