deepagents 0.0.6rc2__tar.gz → 0.0.6rc3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/PKG-INFO +31 -57
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/README.md +27 -54
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/deepagents.egg-info/PKG-INFO +31 -57
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/deepagents.egg-info/SOURCES.txt +7 -4
- deepagents-0.0.6rc3/deepagents.egg-info/requires.txt +4 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/deepagents.egg-info/top_level.txt +1 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/pyproject.toml +6 -4
- deepagents-0.0.6rc3/src/deepagents/__init__.py +5 -0
- deepagents-0.0.6rc3/src/deepagents/graph.py +146 -0
- deepagents-0.0.6rc3/src/deepagents/middleware.py +198 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/src/deepagents/prompts.py +14 -13
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/src/deepagents/state.py +9 -1
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/src/deepagents/tools.py +7 -8
- deepagents-0.0.6rc3/src/deepagents/types.py +21 -0
- deepagents-0.0.6rc3/tests/test_deepagents.py +136 -0
- deepagents-0.0.6rc3/tests/test_hitl.py +51 -0
- deepagents-0.0.6rc3/tests/test_middleware.py +57 -0
- deepagents-0.0.6rc3/tests/utils.py +81 -0
- deepagents-0.0.6rc2/deepagents.egg-info/requires.txt +0 -3
- deepagents-0.0.6rc2/src/deepagents/__init__.py +0 -9
- deepagents-0.0.6rc2/src/deepagents/builder.py +0 -84
- deepagents-0.0.6rc2/src/deepagents/graph.py +0 -219
- deepagents-0.0.6rc2/src/deepagents/interrupt.py +0 -122
- deepagents-0.0.6rc2/src/deepagents/sub_agent.py +0 -169
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/LICENSE +0 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/deepagents.egg-info/dependency_links.txt +0 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/setup.cfg +0 -0
- {deepagents-0.0.6rc2 → deepagents-0.0.6rc3}/src/deepagents/model.py +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepagents
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6rc3
|
|
4
4
|
Summary: General purpose 'deep agent' with sub-agent spawning, todo list capabilities, and mock file system. Built on LangGraph.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: <4.0,>=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
9
|
-
Requires-Dist: langgraph>=0.
|
|
9
|
+
Requires-Dist: langgraph>=1.0.0a3
|
|
10
10
|
Requires-Dist: langchain-anthropic>=0.1.23
|
|
11
|
-
Requires-Dist: langchain>=0.
|
|
11
|
+
Requires-Dist: langchain>=1.0.0a7
|
|
12
|
+
Requires-Dist: langgraph-prebuilt>=0.7.0a2
|
|
12
13
|
Dynamic: license-file
|
|
13
14
|
|
|
14
15
|
# 🧠🤖Deep Agents
|
|
@@ -37,7 +38,7 @@ pip install deepagents
|
|
|
37
38
|
```python
|
|
38
39
|
import os
|
|
39
40
|
from typing import Literal
|
|
40
|
-
|
|
41
|
+
from langchain_core.tools import tool
|
|
41
42
|
from tavily import TavilyClient
|
|
42
43
|
from deepagents import create_deep_agent
|
|
43
44
|
|
|
@@ -86,7 +87,7 @@ in the same way you would any LangGraph agent.
|
|
|
86
87
|
|
|
87
88
|
## Creating a custom deep agent
|
|
88
89
|
|
|
89
|
-
There are
|
|
90
|
+
There are several parameters you can pass to `create_deep_agent` to create your own custom deep agent.
|
|
90
91
|
|
|
91
92
|
### `tools` (Required)
|
|
92
93
|
|
|
@@ -98,7 +99,7 @@ The agent (and any subagents) will have access to these tools.
|
|
|
98
99
|
|
|
99
100
|
The second argument to `create_deep_agent` is `instructions`.
|
|
100
101
|
This will serve as part of the prompt of the deep agent.
|
|
101
|
-
Note that
|
|
102
|
+
Note that our deep agent middleware appends further instructions to the deep agent regarding to-do list, filesystem, and subagent usage, so this is not the *entire* prompt the agent will see.
|
|
102
103
|
|
|
103
104
|
### `subagents` (Optional)
|
|
104
105
|
|
|
@@ -114,7 +115,8 @@ class SubAgent(TypedDict):
|
|
|
114
115
|
description: str
|
|
115
116
|
prompt: str
|
|
116
117
|
tools: NotRequired[list[str]]
|
|
117
|
-
|
|
118
|
+
model: NotRequired[Union[LanguageModelLike, dict[str, Any]]]
|
|
119
|
+
middleware: NotRequired[list[AgentMiddleware]]
|
|
118
120
|
|
|
119
121
|
class CustomSubAgent(TypedDict):
|
|
120
122
|
name: str
|
|
@@ -127,7 +129,8 @@ class CustomSubAgent(TypedDict):
|
|
|
127
129
|
- **description**: This is the description of the subagent that is shown to the main agent
|
|
128
130
|
- **prompt**: This is the prompt used for the subagent
|
|
129
131
|
- **tools**: This is the list of tools that the subagent has access to. By default will have access to all tools passed in, as well as all built-in tools.
|
|
130
|
-
- **
|
|
132
|
+
- **model**: Optional model instance OR dictionary for per-subagent model configuration (inherits the main model when omitted).
|
|
133
|
+
- **middleware** Additional middleware to attach to the subagent. See [here](https://docs.langchain.com/oss/python/langchain/middleware) for an introduction into middleware and how it works with create_agent.
|
|
131
134
|
|
|
132
135
|
**CustomSubAgent fields:**
|
|
133
136
|
- **name**: This is the name of the subagent, and how the main agent will call the subagent
|
|
@@ -141,6 +144,7 @@ research_subagent = {
|
|
|
141
144
|
"name": "research-agent",
|
|
142
145
|
"description": "Used to research more in depth questions",
|
|
143
146
|
"prompt": sub_research_prompt,
|
|
147
|
+
"tools": [internet_search]
|
|
144
148
|
}
|
|
145
149
|
subagents = [research_subagent]
|
|
146
150
|
agent = create_deep_agent(
|
|
@@ -183,18 +187,6 @@ agent = create_deep_agent(
|
|
|
183
187
|
|
|
184
188
|
By default, `deepagents` uses `"claude-sonnet-4-20250514"`. You can customize this by passing any [LangChain model object](https://python.langchain.com/docs/integrations/chat/).
|
|
185
189
|
|
|
186
|
-
### `builtin_tools` (Optional)
|
|
187
|
-
|
|
188
|
-
By default, a deep agent will have access to a number of [built-in tools](#builtintools--optional-).
|
|
189
|
-
You can change this by specifying the tools (by name) that the agent should have access to with this parameter.
|
|
190
|
-
|
|
191
|
-
Example:
|
|
192
|
-
```python
|
|
193
|
-
# Only give agent access to todo tool, none of the filesystem tools
|
|
194
|
-
builtin_tools = ["write_todos"]
|
|
195
|
-
agent = create_deep_agent(..., builtin_tools=builtin_tools, ...)
|
|
196
|
-
```
|
|
197
|
-
|
|
198
190
|
#### Example: Using a Custom Model
|
|
199
191
|
|
|
200
192
|
Here's how to use a custom model (like OpenAI's `gpt-oss` model via Ollama):
|
|
@@ -243,6 +235,15 @@ agent = create_deep_agent(
|
|
|
243
235
|
)
|
|
244
236
|
```
|
|
245
237
|
|
|
238
|
+
|
|
239
|
+
### `middleware` (Optional)
|
|
240
|
+
Both the main agent and sub-agents can take additional custom AgentMiddleware. Middleware is the best supported approach for extending the state_schema, adding additional tools, and adding pre / post model hooks. See this [doc](https://docs.langchain.com/oss/python/langchain/middleware) to learn more about Middleware and how you can use it!
|
|
241
|
+
|
|
242
|
+
### `tool_configs` (Optional)
|
|
243
|
+
Tool configs are used to specify how to handle Human In The Loop interactions on certain tools that require additional human oversight.
|
|
244
|
+
|
|
245
|
+
These tool_configs are passed to our prebuilt [HITL middleware](https://docs.langchain.com/oss/python/langchain/middleware#human-in-the-loop) so that the agent pauses execution and waits for feedback from the user before executing configured tools.
|
|
246
|
+
|
|
246
247
|
## Deep Agent Details
|
|
247
248
|
|
|
248
249
|
The below components are built into `deepagents` and helps make it work for deep tasks off-the-shelf.
|
|
@@ -304,25 +305,20 @@ By default, deep agents come with five built-in tools:
|
|
|
304
305
|
- `ls`: Tool for listing files in the virtual filesystem
|
|
305
306
|
- `edit_file`: Tool for editing a file in the virtual filesystem
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
If you want to omit some deepagents functionality, use specific middleware components directly!
|
|
308
309
|
|
|
309
310
|
### Human-in-the-Loop
|
|
310
311
|
|
|
311
|
-
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `
|
|
312
|
+
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `tool_configs` parameter, which maps tool names to a `HumanInTheLoopConfig`.
|
|
312
313
|
|
|
313
|
-
`
|
|
314
|
+
`HumanInTheLoopConfig` is how you specify what type of human in the loop patterns are supported.
|
|
314
315
|
It is a dictionary with four specific keys:
|
|
315
316
|
|
|
316
|
-
- `
|
|
317
|
-
- `allow_respond`: Whether the
|
|
318
|
-
- `allow_edit`: Whether the
|
|
319
|
-
- `allow_accept`: Whether the user can accept the tool call
|
|
320
|
-
|
|
321
|
-
Currently, `deepagents` does NOT support `allow_ignore`
|
|
317
|
+
- `allow_accept`: Whether the human can approve the current action without changes
|
|
318
|
+
- `allow_respond`: Whether the human can reject the current action with feedback
|
|
319
|
+
- `allow_edit`: Whether the human can approve the current action with edited content
|
|
322
320
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
Instead of specifying a `HumanInterruptConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
321
|
+
Instead of specifying a `HumanInTheLoopConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
326
322
|
|
|
327
323
|
In order to use human in the loop, you need to have a checkpointer attached.
|
|
328
324
|
Note: if you are using LangGraph Platform, this is automatically attached.
|
|
@@ -337,10 +333,9 @@ from langgraph.checkpoint.memory import InMemorySaver
|
|
|
337
333
|
agent = create_deep_agent(
|
|
338
334
|
tools=[your_tools],
|
|
339
335
|
instructions="Your instructions here",
|
|
340
|
-
|
|
336
|
+
tool_configs={
|
|
341
337
|
# You can specify a dictionary for fine grained control over what interrupt options exist
|
|
342
338
|
"tool_1": {
|
|
343
|
-
"allow_ignore": False,
|
|
344
339
|
"allow_respond": True,
|
|
345
340
|
"allow_edit": True,
|
|
346
341
|
"allow_accept":True,
|
|
@@ -413,12 +408,12 @@ for s in agent.stream(Command(resume=[{"type": "response", "args": "..."}]), con
|
|
|
413
408
|
```
|
|
414
409
|
## Async
|
|
415
410
|
|
|
416
|
-
If you are passing async tools to your agent, you will want to `from deepagents import async_create_deep_agent`
|
|
411
|
+
If you are passing async tools to your agent, you will want to use `from deepagents import async_create_deep_agent`
|
|
417
412
|
## MCP
|
|
418
413
|
|
|
419
414
|
The `deepagents` library can be ran with MCP tools. This can be achieved by using the [Langchain MCP Adapter library](https://github.com/langchain-ai/langchain-mcp-adapters).
|
|
420
415
|
|
|
421
|
-
**NOTE:** will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
416
|
+
**NOTE:** You will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
422
417
|
|
|
423
418
|
(To run the example below, will need to `pip install langchain-mcp-adapters`)
|
|
424
419
|
|
|
@@ -446,27 +441,6 @@ async def main():
|
|
|
446
441
|
asyncio.run(main())
|
|
447
442
|
```
|
|
448
443
|
|
|
449
|
-
## Configurable Agent
|
|
450
|
-
|
|
451
|
-
Configurable agents allow you to control the agent via a config passed in.
|
|
452
|
-
|
|
453
|
-
```python
|
|
454
|
-
from deepagents import create_configurable_agent
|
|
455
|
-
|
|
456
|
-
agent_config = {"instructions": "foo", "subagents": []}
|
|
457
|
-
|
|
458
|
-
build_agent = create_configurable_agent(
|
|
459
|
-
agent_config['instructions'],
|
|
460
|
-
agent_config['subagents'],
|
|
461
|
-
[],
|
|
462
|
-
agent_config={"recursion_limit": 1000}
|
|
463
|
-
)
|
|
464
|
-
```
|
|
465
|
-
You can now use `build_agent` in your `langgraph.json` and deploy it with `langgraph dev`
|
|
466
|
-
|
|
467
|
-
For async tools, you can use `from deepagents import async_create_configurable_agent`
|
|
468
|
-
|
|
469
|
-
|
|
470
444
|
## Roadmap
|
|
471
445
|
- [ ] Allow users to customize full system prompt
|
|
472
446
|
- [ ] Code cleanliness (type hinting, docstrings, formating)
|
|
@@ -24,7 +24,7 @@ pip install deepagents
|
|
|
24
24
|
```python
|
|
25
25
|
import os
|
|
26
26
|
from typing import Literal
|
|
27
|
-
|
|
27
|
+
from langchain_core.tools import tool
|
|
28
28
|
from tavily import TavilyClient
|
|
29
29
|
from deepagents import create_deep_agent
|
|
30
30
|
|
|
@@ -73,7 +73,7 @@ in the same way you would any LangGraph agent.
|
|
|
73
73
|
|
|
74
74
|
## Creating a custom deep agent
|
|
75
75
|
|
|
76
|
-
There are
|
|
76
|
+
There are several parameters you can pass to `create_deep_agent` to create your own custom deep agent.
|
|
77
77
|
|
|
78
78
|
### `tools` (Required)
|
|
79
79
|
|
|
@@ -85,7 +85,7 @@ The agent (and any subagents) will have access to these tools.
|
|
|
85
85
|
|
|
86
86
|
The second argument to `create_deep_agent` is `instructions`.
|
|
87
87
|
This will serve as part of the prompt of the deep agent.
|
|
88
|
-
Note that
|
|
88
|
+
Note that our deep agent middleware appends further instructions to the deep agent regarding to-do list, filesystem, and subagent usage, so this is not the *entire* prompt the agent will see.
|
|
89
89
|
|
|
90
90
|
### `subagents` (Optional)
|
|
91
91
|
|
|
@@ -101,7 +101,8 @@ class SubAgent(TypedDict):
|
|
|
101
101
|
description: str
|
|
102
102
|
prompt: str
|
|
103
103
|
tools: NotRequired[list[str]]
|
|
104
|
-
|
|
104
|
+
model: NotRequired[Union[LanguageModelLike, dict[str, Any]]]
|
|
105
|
+
middleware: NotRequired[list[AgentMiddleware]]
|
|
105
106
|
|
|
106
107
|
class CustomSubAgent(TypedDict):
|
|
107
108
|
name: str
|
|
@@ -114,7 +115,8 @@ class CustomSubAgent(TypedDict):
|
|
|
114
115
|
- **description**: This is the description of the subagent that is shown to the main agent
|
|
115
116
|
- **prompt**: This is the prompt used for the subagent
|
|
116
117
|
- **tools**: This is the list of tools that the subagent has access to. By default will have access to all tools passed in, as well as all built-in tools.
|
|
117
|
-
- **
|
|
118
|
+
- **model**: Optional model instance OR dictionary for per-subagent model configuration (inherits the main model when omitted).
|
|
119
|
+
- **middleware** Additional middleware to attach to the subagent. See [here](https://docs.langchain.com/oss/python/langchain/middleware) for an introduction into middleware and how it works with create_agent.
|
|
118
120
|
|
|
119
121
|
**CustomSubAgent fields:**
|
|
120
122
|
- **name**: This is the name of the subagent, and how the main agent will call the subagent
|
|
@@ -128,6 +130,7 @@ research_subagent = {
|
|
|
128
130
|
"name": "research-agent",
|
|
129
131
|
"description": "Used to research more in depth questions",
|
|
130
132
|
"prompt": sub_research_prompt,
|
|
133
|
+
"tools": [internet_search]
|
|
131
134
|
}
|
|
132
135
|
subagents = [research_subagent]
|
|
133
136
|
agent = create_deep_agent(
|
|
@@ -170,18 +173,6 @@ agent = create_deep_agent(
|
|
|
170
173
|
|
|
171
174
|
By default, `deepagents` uses `"claude-sonnet-4-20250514"`. You can customize this by passing any [LangChain model object](https://python.langchain.com/docs/integrations/chat/).
|
|
172
175
|
|
|
173
|
-
### `builtin_tools` (Optional)
|
|
174
|
-
|
|
175
|
-
By default, a deep agent will have access to a number of [built-in tools](#builtintools--optional-).
|
|
176
|
-
You can change this by specifying the tools (by name) that the agent should have access to with this parameter.
|
|
177
|
-
|
|
178
|
-
Example:
|
|
179
|
-
```python
|
|
180
|
-
# Only give agent access to todo tool, none of the filesystem tools
|
|
181
|
-
builtin_tools = ["write_todos"]
|
|
182
|
-
agent = create_deep_agent(..., builtin_tools=builtin_tools, ...)
|
|
183
|
-
```
|
|
184
|
-
|
|
185
176
|
#### Example: Using a Custom Model
|
|
186
177
|
|
|
187
178
|
Here's how to use a custom model (like OpenAI's `gpt-oss` model via Ollama):
|
|
@@ -230,6 +221,15 @@ agent = create_deep_agent(
|
|
|
230
221
|
)
|
|
231
222
|
```
|
|
232
223
|
|
|
224
|
+
|
|
225
|
+
### `middleware` (Optional)
|
|
226
|
+
Both the main agent and sub-agents can take additional custom AgentMiddleware. Middleware is the best supported approach for extending the state_schema, adding additional tools, and adding pre / post model hooks. See this [doc](https://docs.langchain.com/oss/python/langchain/middleware) to learn more about Middleware and how you can use it!
|
|
227
|
+
|
|
228
|
+
### `tool_configs` (Optional)
|
|
229
|
+
Tool configs are used to specify how to handle Human In The Loop interactions on certain tools that require additional human oversight.
|
|
230
|
+
|
|
231
|
+
These tool_configs are passed to our prebuilt [HITL middleware](https://docs.langchain.com/oss/python/langchain/middleware#human-in-the-loop) so that the agent pauses execution and waits for feedback from the user before executing configured tools.
|
|
232
|
+
|
|
233
233
|
## Deep Agent Details
|
|
234
234
|
|
|
235
235
|
The below components are built into `deepagents` and helps make it work for deep tasks off-the-shelf.
|
|
@@ -291,25 +291,20 @@ By default, deep agents come with five built-in tools:
|
|
|
291
291
|
- `ls`: Tool for listing files in the virtual filesystem
|
|
292
292
|
- `edit_file`: Tool for editing a file in the virtual filesystem
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
If you want to omit some deepagents functionality, use specific middleware components directly!
|
|
295
295
|
|
|
296
296
|
### Human-in-the-Loop
|
|
297
297
|
|
|
298
|
-
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `
|
|
298
|
+
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `tool_configs` parameter, which maps tool names to a `HumanInTheLoopConfig`.
|
|
299
299
|
|
|
300
|
-
`
|
|
300
|
+
`HumanInTheLoopConfig` is how you specify what type of human in the loop patterns are supported.
|
|
301
301
|
It is a dictionary with four specific keys:
|
|
302
302
|
|
|
303
|
-
- `
|
|
304
|
-
- `allow_respond`: Whether the
|
|
305
|
-
- `allow_edit`: Whether the
|
|
306
|
-
- `allow_accept`: Whether the user can accept the tool call
|
|
307
|
-
|
|
308
|
-
Currently, `deepagents` does NOT support `allow_ignore`
|
|
303
|
+
- `allow_accept`: Whether the human can approve the current action without changes
|
|
304
|
+
- `allow_respond`: Whether the human can reject the current action with feedback
|
|
305
|
+
- `allow_edit`: Whether the human can approve the current action with edited content
|
|
309
306
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
Instead of specifying a `HumanInterruptConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
307
|
+
Instead of specifying a `HumanInTheLoopConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
313
308
|
|
|
314
309
|
In order to use human in the loop, you need to have a checkpointer attached.
|
|
315
310
|
Note: if you are using LangGraph Platform, this is automatically attached.
|
|
@@ -324,10 +319,9 @@ from langgraph.checkpoint.memory import InMemorySaver
|
|
|
324
319
|
agent = create_deep_agent(
|
|
325
320
|
tools=[your_tools],
|
|
326
321
|
instructions="Your instructions here",
|
|
327
|
-
|
|
322
|
+
tool_configs={
|
|
328
323
|
# You can specify a dictionary for fine grained control over what interrupt options exist
|
|
329
324
|
"tool_1": {
|
|
330
|
-
"allow_ignore": False,
|
|
331
325
|
"allow_respond": True,
|
|
332
326
|
"allow_edit": True,
|
|
333
327
|
"allow_accept":True,
|
|
@@ -400,12 +394,12 @@ for s in agent.stream(Command(resume=[{"type": "response", "args": "..."}]), con
|
|
|
400
394
|
```
|
|
401
395
|
## Async
|
|
402
396
|
|
|
403
|
-
If you are passing async tools to your agent, you will want to `from deepagents import async_create_deep_agent`
|
|
397
|
+
If you are passing async tools to your agent, you will want to use `from deepagents import async_create_deep_agent`
|
|
404
398
|
## MCP
|
|
405
399
|
|
|
406
400
|
The `deepagents` library can be ran with MCP tools. This can be achieved by using the [Langchain MCP Adapter library](https://github.com/langchain-ai/langchain-mcp-adapters).
|
|
407
401
|
|
|
408
|
-
**NOTE:** will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
402
|
+
**NOTE:** You will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
409
403
|
|
|
410
404
|
(To run the example below, will need to `pip install langchain-mcp-adapters`)
|
|
411
405
|
|
|
@@ -433,27 +427,6 @@ async def main():
|
|
|
433
427
|
asyncio.run(main())
|
|
434
428
|
```
|
|
435
429
|
|
|
436
|
-
## Configurable Agent
|
|
437
|
-
|
|
438
|
-
Configurable agents allow you to control the agent via a config passed in.
|
|
439
|
-
|
|
440
|
-
```python
|
|
441
|
-
from deepagents import create_configurable_agent
|
|
442
|
-
|
|
443
|
-
agent_config = {"instructions": "foo", "subagents": []}
|
|
444
|
-
|
|
445
|
-
build_agent = create_configurable_agent(
|
|
446
|
-
agent_config['instructions'],
|
|
447
|
-
agent_config['subagents'],
|
|
448
|
-
[],
|
|
449
|
-
agent_config={"recursion_limit": 1000}
|
|
450
|
-
)
|
|
451
|
-
```
|
|
452
|
-
You can now use `build_agent` in your `langgraph.json` and deploy it with `langgraph dev`
|
|
453
|
-
|
|
454
|
-
For async tools, you can use `from deepagents import async_create_configurable_agent`
|
|
455
|
-
|
|
456
|
-
|
|
457
430
|
## Roadmap
|
|
458
431
|
- [ ] Allow users to customize full system prompt
|
|
459
432
|
- [ ] Code cleanliness (type hinting, docstrings, formating)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepagents
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6rc3
|
|
4
4
|
Summary: General purpose 'deep agent' with sub-agent spawning, todo list capabilities, and mock file system. Built on LangGraph.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: <4.0,>=3.11
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
9
|
-
Requires-Dist: langgraph>=0.
|
|
9
|
+
Requires-Dist: langgraph>=1.0.0a3
|
|
10
10
|
Requires-Dist: langchain-anthropic>=0.1.23
|
|
11
|
-
Requires-Dist: langchain>=0.
|
|
11
|
+
Requires-Dist: langchain>=1.0.0a7
|
|
12
|
+
Requires-Dist: langgraph-prebuilt>=0.7.0a2
|
|
12
13
|
Dynamic: license-file
|
|
13
14
|
|
|
14
15
|
# 🧠🤖Deep Agents
|
|
@@ -37,7 +38,7 @@ pip install deepagents
|
|
|
37
38
|
```python
|
|
38
39
|
import os
|
|
39
40
|
from typing import Literal
|
|
40
|
-
|
|
41
|
+
from langchain_core.tools import tool
|
|
41
42
|
from tavily import TavilyClient
|
|
42
43
|
from deepagents import create_deep_agent
|
|
43
44
|
|
|
@@ -86,7 +87,7 @@ in the same way you would any LangGraph agent.
|
|
|
86
87
|
|
|
87
88
|
## Creating a custom deep agent
|
|
88
89
|
|
|
89
|
-
There are
|
|
90
|
+
There are several parameters you can pass to `create_deep_agent` to create your own custom deep agent.
|
|
90
91
|
|
|
91
92
|
### `tools` (Required)
|
|
92
93
|
|
|
@@ -98,7 +99,7 @@ The agent (and any subagents) will have access to these tools.
|
|
|
98
99
|
|
|
99
100
|
The second argument to `create_deep_agent` is `instructions`.
|
|
100
101
|
This will serve as part of the prompt of the deep agent.
|
|
101
|
-
Note that
|
|
102
|
+
Note that our deep agent middleware appends further instructions to the deep agent regarding to-do list, filesystem, and subagent usage, so this is not the *entire* prompt the agent will see.
|
|
102
103
|
|
|
103
104
|
### `subagents` (Optional)
|
|
104
105
|
|
|
@@ -114,7 +115,8 @@ class SubAgent(TypedDict):
|
|
|
114
115
|
description: str
|
|
115
116
|
prompt: str
|
|
116
117
|
tools: NotRequired[list[str]]
|
|
117
|
-
|
|
118
|
+
model: NotRequired[Union[LanguageModelLike, dict[str, Any]]]
|
|
119
|
+
middleware: NotRequired[list[AgentMiddleware]]
|
|
118
120
|
|
|
119
121
|
class CustomSubAgent(TypedDict):
|
|
120
122
|
name: str
|
|
@@ -127,7 +129,8 @@ class CustomSubAgent(TypedDict):
|
|
|
127
129
|
- **description**: This is the description of the subagent that is shown to the main agent
|
|
128
130
|
- **prompt**: This is the prompt used for the subagent
|
|
129
131
|
- **tools**: This is the list of tools that the subagent has access to. By default will have access to all tools passed in, as well as all built-in tools.
|
|
130
|
-
- **
|
|
132
|
+
- **model**: Optional model instance OR dictionary for per-subagent model configuration (inherits the main model when omitted).
|
|
133
|
+
- **middleware** Additional middleware to attach to the subagent. See [here](https://docs.langchain.com/oss/python/langchain/middleware) for an introduction into middleware and how it works with create_agent.
|
|
131
134
|
|
|
132
135
|
**CustomSubAgent fields:**
|
|
133
136
|
- **name**: This is the name of the subagent, and how the main agent will call the subagent
|
|
@@ -141,6 +144,7 @@ research_subagent = {
|
|
|
141
144
|
"name": "research-agent",
|
|
142
145
|
"description": "Used to research more in depth questions",
|
|
143
146
|
"prompt": sub_research_prompt,
|
|
147
|
+
"tools": [internet_search]
|
|
144
148
|
}
|
|
145
149
|
subagents = [research_subagent]
|
|
146
150
|
agent = create_deep_agent(
|
|
@@ -183,18 +187,6 @@ agent = create_deep_agent(
|
|
|
183
187
|
|
|
184
188
|
By default, `deepagents` uses `"claude-sonnet-4-20250514"`. You can customize this by passing any [LangChain model object](https://python.langchain.com/docs/integrations/chat/).
|
|
185
189
|
|
|
186
|
-
### `builtin_tools` (Optional)
|
|
187
|
-
|
|
188
|
-
By default, a deep agent will have access to a number of [built-in tools](#builtintools--optional-).
|
|
189
|
-
You can change this by specifying the tools (by name) that the agent should have access to with this parameter.
|
|
190
|
-
|
|
191
|
-
Example:
|
|
192
|
-
```python
|
|
193
|
-
# Only give agent access to todo tool, none of the filesystem tools
|
|
194
|
-
builtin_tools = ["write_todos"]
|
|
195
|
-
agent = create_deep_agent(..., builtin_tools=builtin_tools, ...)
|
|
196
|
-
```
|
|
197
|
-
|
|
198
190
|
#### Example: Using a Custom Model
|
|
199
191
|
|
|
200
192
|
Here's how to use a custom model (like OpenAI's `gpt-oss` model via Ollama):
|
|
@@ -243,6 +235,15 @@ agent = create_deep_agent(
|
|
|
243
235
|
)
|
|
244
236
|
```
|
|
245
237
|
|
|
238
|
+
|
|
239
|
+
### `middleware` (Optional)
|
|
240
|
+
Both the main agent and sub-agents can take additional custom AgentMiddleware. Middleware is the best supported approach for extending the state_schema, adding additional tools, and adding pre / post model hooks. See this [doc](https://docs.langchain.com/oss/python/langchain/middleware) to learn more about Middleware and how you can use it!
|
|
241
|
+
|
|
242
|
+
### `tool_configs` (Optional)
|
|
243
|
+
Tool configs are used to specify how to handle Human In The Loop interactions on certain tools that require additional human oversight.
|
|
244
|
+
|
|
245
|
+
These tool_configs are passed to our prebuilt [HITL middleware](https://docs.langchain.com/oss/python/langchain/middleware#human-in-the-loop) so that the agent pauses execution and waits for feedback from the user before executing configured tools.
|
|
246
|
+
|
|
246
247
|
## Deep Agent Details
|
|
247
248
|
|
|
248
249
|
The below components are built into `deepagents` and helps make it work for deep tasks off-the-shelf.
|
|
@@ -304,25 +305,20 @@ By default, deep agents come with five built-in tools:
|
|
|
304
305
|
- `ls`: Tool for listing files in the virtual filesystem
|
|
305
306
|
- `edit_file`: Tool for editing a file in the virtual filesystem
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
If you want to omit some deepagents functionality, use specific middleware components directly!
|
|
308
309
|
|
|
309
310
|
### Human-in-the-Loop
|
|
310
311
|
|
|
311
|
-
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `
|
|
312
|
+
`deepagents` supports human-in-the-loop approval for tool execution. You can configure specific tools to require human approval before execution using the `tool_configs` parameter, which maps tool names to a `HumanInTheLoopConfig`.
|
|
312
313
|
|
|
313
|
-
`
|
|
314
|
+
`HumanInTheLoopConfig` is how you specify what type of human in the loop patterns are supported.
|
|
314
315
|
It is a dictionary with four specific keys:
|
|
315
316
|
|
|
316
|
-
- `
|
|
317
|
-
- `allow_respond`: Whether the
|
|
318
|
-
- `allow_edit`: Whether the
|
|
319
|
-
- `allow_accept`: Whether the user can accept the tool call
|
|
320
|
-
|
|
321
|
-
Currently, `deepagents` does NOT support `allow_ignore`
|
|
317
|
+
- `allow_accept`: Whether the human can approve the current action without changes
|
|
318
|
+
- `allow_respond`: Whether the human can reject the current action with feedback
|
|
319
|
+
- `allow_edit`: Whether the human can approve the current action with edited content
|
|
322
320
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
Instead of specifying a `HumanInterruptConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
321
|
+
Instead of specifying a `HumanInTheLoopConfig` for a tool, you can also just set `True`. This will set `allow_ignore`, `allow_respond`, `allow_edit`, and `allow_accept` to be `True`.
|
|
326
322
|
|
|
327
323
|
In order to use human in the loop, you need to have a checkpointer attached.
|
|
328
324
|
Note: if you are using LangGraph Platform, this is automatically attached.
|
|
@@ -337,10 +333,9 @@ from langgraph.checkpoint.memory import InMemorySaver
|
|
|
337
333
|
agent = create_deep_agent(
|
|
338
334
|
tools=[your_tools],
|
|
339
335
|
instructions="Your instructions here",
|
|
340
|
-
|
|
336
|
+
tool_configs={
|
|
341
337
|
# You can specify a dictionary for fine grained control over what interrupt options exist
|
|
342
338
|
"tool_1": {
|
|
343
|
-
"allow_ignore": False,
|
|
344
339
|
"allow_respond": True,
|
|
345
340
|
"allow_edit": True,
|
|
346
341
|
"allow_accept":True,
|
|
@@ -413,12 +408,12 @@ for s in agent.stream(Command(resume=[{"type": "response", "args": "..."}]), con
|
|
|
413
408
|
```
|
|
414
409
|
## Async
|
|
415
410
|
|
|
416
|
-
If you are passing async tools to your agent, you will want to `from deepagents import async_create_deep_agent`
|
|
411
|
+
If you are passing async tools to your agent, you will want to use `from deepagents import async_create_deep_agent`
|
|
417
412
|
## MCP
|
|
418
413
|
|
|
419
414
|
The `deepagents` library can be ran with MCP tools. This can be achieved by using the [Langchain MCP Adapter library](https://github.com/langchain-ai/langchain-mcp-adapters).
|
|
420
415
|
|
|
421
|
-
**NOTE:** will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
416
|
+
**NOTE:** You will want to use `from deepagents import async_create_deep_agent` to use the async version of `deepagents`, since MCP tools are async
|
|
422
417
|
|
|
423
418
|
(To run the example below, will need to `pip install langchain-mcp-adapters`)
|
|
424
419
|
|
|
@@ -446,27 +441,6 @@ async def main():
|
|
|
446
441
|
asyncio.run(main())
|
|
447
442
|
```
|
|
448
443
|
|
|
449
|
-
## Configurable Agent
|
|
450
|
-
|
|
451
|
-
Configurable agents allow you to control the agent via a config passed in.
|
|
452
|
-
|
|
453
|
-
```python
|
|
454
|
-
from deepagents import create_configurable_agent
|
|
455
|
-
|
|
456
|
-
agent_config = {"instructions": "foo", "subagents": []}
|
|
457
|
-
|
|
458
|
-
build_agent = create_configurable_agent(
|
|
459
|
-
agent_config['instructions'],
|
|
460
|
-
agent_config['subagents'],
|
|
461
|
-
[],
|
|
462
|
-
agent_config={"recursion_limit": 1000}
|
|
463
|
-
)
|
|
464
|
-
```
|
|
465
|
-
You can now use `build_agent` in your `langgraph.json` and deploy it with `langgraph dev`
|
|
466
|
-
|
|
467
|
-
For async tools, you can use `from deepagents import async_create_configurable_agent`
|
|
468
|
-
|
|
469
|
-
|
|
470
444
|
## Roadmap
|
|
471
445
|
- [ ] Allow users to customize full system prompt
|
|
472
446
|
- [ ] Code cleanliness (type hinting, docstrings, formating)
|
|
@@ -7,11 +7,14 @@ deepagents.egg-info/dependency_links.txt
|
|
|
7
7
|
deepagents.egg-info/requires.txt
|
|
8
8
|
deepagents.egg-info/top_level.txt
|
|
9
9
|
src/deepagents/__init__.py
|
|
10
|
-
src/deepagents/builder.py
|
|
11
10
|
src/deepagents/graph.py
|
|
12
|
-
src/deepagents/
|
|
11
|
+
src/deepagents/middleware.py
|
|
13
12
|
src/deepagents/model.py
|
|
14
13
|
src/deepagents/prompts.py
|
|
15
14
|
src/deepagents/state.py
|
|
16
|
-
src/deepagents/
|
|
17
|
-
src/deepagents/
|
|
15
|
+
src/deepagents/tools.py
|
|
16
|
+
src/deepagents/types.py
|
|
17
|
+
tests/test_deepagents.py
|
|
18
|
+
tests/test_hitl.py
|
|
19
|
+
tests/test_middleware.py
|
|
20
|
+
tests/utils.py
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "deepagents"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.6rc3"
|
|
4
4
|
description = "General purpose 'deep agent' with sub-agent spawning, todo list capabilities, and mock file system. Built on LangGraph."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { text = "MIT" }
|
|
7
7
|
requires-python = ">=3.11,<4.0"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"langgraph>=0.
|
|
9
|
+
"langgraph>=1.0.0a3",
|
|
10
10
|
"langchain-anthropic>=0.1.23",
|
|
11
|
-
"langchain>=0.
|
|
11
|
+
"langchain>=1.0.0a7",
|
|
12
|
+
"langgraph-prebuilt>=0.7.0a2",
|
|
12
13
|
]
|
|
13
14
|
|
|
14
15
|
|
|
@@ -17,9 +18,10 @@ requires = ["setuptools>=73.0.0", "wheel"]
|
|
|
17
18
|
build-backend = "setuptools.build_meta"
|
|
18
19
|
|
|
19
20
|
[tool.setuptools]
|
|
20
|
-
packages = ["deepagents"]
|
|
21
|
+
packages = ["deepagents", "tests"]
|
|
21
22
|
[tool.setuptools.package-dir]
|
|
22
23
|
"deepagents" = "src/deepagents"
|
|
24
|
+
"tests" = "tests"
|
|
23
25
|
|
|
24
26
|
[tool.setuptools.package-data]
|
|
25
27
|
"*" = ["py.typed"]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from deepagents.graph import create_deep_agent, async_create_deep_agent
|
|
2
|
+
from deepagents.middleware import PlanningMiddleware, FilesystemMiddleware, SubAgentMiddleware
|
|
3
|
+
from deepagents.state import DeepAgentState
|
|
4
|
+
from deepagents.types import SubAgent, CustomSubAgent
|
|
5
|
+
from deepagents.model import get_default_model
|