deepagents-cli 0.0.2__py3-none-any.whl → 0.0.4__py3-none-any.whl

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.

Potentially problematic release.


This version of deepagents-cli might be problematic. Click here for more details.

deepagents/graph.py DELETED
@@ -1,168 +0,0 @@
1
- """Deepagents come with planning, filesystem, and subagents."""
2
-
3
- from collections.abc import Callable, Sequence
4
- from typing import Any
5
- import os
6
-
7
- from langchain.agents import create_agent
8
- from langchain.agents.middleware import HumanInTheLoopMiddleware, InterruptOnConfig, TodoListMiddleware
9
- from langchain.agents.middleware.summarization import SummarizationMiddleware
10
- from langchain.agents.middleware.types import AgentMiddleware
11
- from langchain.agents.structured_output import ResponseFormat
12
- from langchain_anthropic import ChatAnthropic
13
- from langchain_anthropic.middleware import AnthropicPromptCachingMiddleware
14
- from langchain.agents.middleware import ShellToolMiddleware, HostExecutionPolicy
15
- from langchain_core.language_models import BaseChatModel
16
- from langchain_core.tools import BaseTool
17
- from langgraph.cache.base import BaseCache
18
- from langgraph.graph.state import CompiledStateGraph
19
- from langgraph.store.base import BaseStore
20
- from langgraph.types import Checkpointer
21
-
22
- from deepagents.middleware.filesystem import FilesystemMiddleware
23
- from deepagents.middleware.local_filesystem import LocalFilesystemMiddleware
24
- from deepagents.middleware.subagents import CompiledSubAgent, SubAgent, SubAgentMiddleware
25
-
26
- BASE_AGENT_PROMPT = "In order to complete the objective that the user asks of you, you have access to a number of standard tools."
27
-
28
-
29
- def get_default_model() -> ChatAnthropic:
30
- """Get the default model for deep agents.
31
-
32
- Returns:
33
- ChatAnthropic instance configured with Claude Sonnet 4.
34
- """
35
- return ChatAnthropic(
36
- model_name="claude-sonnet-4-5-20250929",
37
- max_tokens=20000,
38
- )
39
-
40
-
41
- def create_deep_agent(
42
- model: str | BaseChatModel | None = None,
43
- tools: Sequence[BaseTool | Callable | dict[str, Any]] | None = None,
44
- *,
45
- system_prompt: str | None = None,
46
- middleware: Sequence[AgentMiddleware] = (),
47
- subagents: list[SubAgent | CompiledSubAgent] | None = None,
48
- response_format: ResponseFormat | None = None,
49
- context_schema: type[Any] | None = None,
50
- checkpointer: Checkpointer | None = None,
51
- store: BaseStore | None = None,
52
- use_longterm_memory: bool = False,
53
- use_local_filesystem: bool = False,
54
- long_term_memory: bool = False,
55
- skills: list[dict[str, Any]] | None = None,
56
- interrupt_on: dict[str, bool | InterruptOnConfig] | None = None,
57
- debug: bool = False,
58
- name: str | None = None,
59
- cache: BaseCache | None = None,
60
- ) -> CompiledStateGraph:
61
- """Create a deep agent.
62
-
63
- This agent will by default have access to a tool to write todos (write_todos),
64
- four file editing tools: write_file, ls, read_file, edit_file, and a tool to call
65
- subagents.
66
-
67
- Args:
68
- tools: The tools the agent should have access to.
69
- system_prompt: The additional instructions the agent should have. Will go in
70
- the system prompt.
71
- middleware: Additional middleware to apply after standard middleware.
72
- model: The model to use.
73
- subagents: The subagents to use. Each subagent should be a dictionary with the
74
- following keys:
75
- - `name`
76
- - `description` (used by the main agent to decide whether to call the
77
- sub agent)
78
- - `prompt` (used as the system prompt in the subagent)
79
- - (optional) `tools`
80
- - (optional) `model` (either a LanguageModelLike instance or dict
81
- settings)
82
- - (optional) `middleware` (list of AgentMiddleware)
83
- response_format: A structured output response format to use for the agent.
84
- context_schema: The schema of the deep agent.
85
- checkpointer: Optional checkpointer for persisting agent state between runs.
86
- store: Optional store for persisting longterm memories.
87
- use_longterm_memory: Whether to use longterm memory - you must provide a store
88
- in order to use longterm memory.
89
- use_local_filesystem: If True, injects LocalFilesystemMiddleware (tools operate on disk).
90
- When True, longterm memory is not supported and `use_longterm_memory` must be False.
91
- Skills are automatically discovered from ~/.deepagents/skills/ and ./.deepagents/skills/.
92
- The agent_name for memory storage can be passed via config: {"configurable": {"agent_name": "myagent"}}.
93
- long_term_memory: If True, enables long-term memory features like agent.md persistence
94
- and memories folder. Only applies when use_local_filesystem=True.
95
- skills: Optional list of SkillDefinition for virtual filesystem mode. Only valid when
96
- use_local_filesystem=False. Skills are loaded into /skills/<name>/ in virtual filesystem.
97
- interrupt_on: Optional Dict[str, bool | InterruptOnConfig] mapping tool names to
98
- interrupt configs.
99
- debug: Whether to enable debug mode. Passed through to create_agent.
100
- name: The name of the agent. Passed through to create_agent.
101
- cache: The cache to use for the agent. Passed through to create_agent.
102
-
103
- Returns:
104
- A configured deep agent.
105
- """
106
- if model is None:
107
- model = get_default_model()
108
-
109
- if use_local_filesystem and skills is not None:
110
- raise ValueError(
111
- "Cannot provide skill definitions with use_local_filesystem=True. "
112
- "Skills are automatically discovered from ~/.deepagents/skills/ and ./.deepagents/skills/. "
113
- "To use custom skills, set use_local_filesystem=False."
114
- )
115
-
116
- # Choose filesystem middleware kind
117
- def _fs_middleware() -> list[AgentMiddleware]:
118
- if use_local_filesystem:
119
- shell_middleware = ShellToolMiddleware(
120
- workspace_root=os.getcwd(),
121
- execution_policy=HostExecutionPolicy()
122
- )
123
- return [LocalFilesystemMiddleware(long_term_memory=long_term_memory), shell_middleware]
124
- return [FilesystemMiddleware(long_term_memory=use_longterm_memory, skills=skills)]
125
-
126
- deepagent_middleware = [
127
- TodoListMiddleware(),
128
- SubAgentMiddleware(
129
- default_model=model,
130
- default_tools=tools,
131
- subagents=subagents if subagents is not None else [],
132
- default_middleware=[
133
- TodoListMiddleware(),
134
- SummarizationMiddleware(
135
- model=model,
136
- max_tokens_before_summary=170000,
137
- messages_to_keep=6,
138
- ),
139
- AnthropicPromptCachingMiddleware(unsupported_model_behavior="ignore"),
140
- ] + _fs_middleware(),
141
- default_interrupt_on=interrupt_on,
142
- general_purpose_agent=True,
143
- ),
144
- SummarizationMiddleware(
145
- model=model,
146
- max_tokens_before_summary=170000,
147
- messages_to_keep=6,
148
- ),
149
- AnthropicPromptCachingMiddleware(unsupported_model_behavior="ignore"),
150
- ] + _fs_middleware()
151
- if interrupt_on is not None:
152
- deepagent_middleware.append(HumanInTheLoopMiddleware(interrupt_on=interrupt_on))
153
- if middleware is not None:
154
- deepagent_middleware.extend(middleware)
155
-
156
- return create_agent(
157
- model,
158
- system_prompt=system_prompt + "\n\n" + BASE_AGENT_PROMPT if system_prompt else BASE_AGENT_PROMPT,
159
- tools=tools,
160
- middleware=deepagent_middleware,
161
- response_format=response_format,
162
- context_schema=context_schema,
163
- checkpointer=checkpointer,
164
- store=store,
165
- debug=debug,
166
- name=name,
167
- cache=cache,
168
- ).with_config({"recursion_limit": 1000})
@@ -1,13 +0,0 @@
1
- """Middleware for the DeepAgent."""
2
-
3
- from deepagents.middleware.filesystem import FilesystemMiddleware
4
- from deepagents.middleware.local_filesystem import LocalFilesystemMiddleware
5
- from deepagents.middleware.subagents import CompiledSubAgent, SubAgent, SubAgentMiddleware
6
-
7
- __all__ = [
8
- "CompiledSubAgent",
9
- "FilesystemMiddleware",
10
- "LocalFilesystemMiddleware",
11
- "SubAgent",
12
- "SubAgentMiddleware",
13
- ]
@@ -1,16 +0,0 @@
1
- """Common middleware constants shared across filesystem middlewares."""
2
-
3
- # Message used when evicting a large tool result to the in-memory filesystem
4
- TOO_LARGE_TOOL_MSG = (
5
- "Tool result too large, the result of this tool call {tool_call_id} was saved in the filesystem at this path: {file_path}\n"
6
- "You can read the result from the filesystem by using the read_file tool, but make sure to only read part of the result at a time.\n"
7
- "You can do this by specifying an offset and limit in the read_file tool call.\n"
8
- "For example, to read the first 100 lines, you can use the read_file tool with offset=0 and limit=100.\n\n"
9
- "Here are the first 10 lines of the result:\n{content_sample}\n"
10
- )
11
-
12
- # Supplement lines for tools that aren't listed in the base filesystem system prompt
13
- FILESYSTEM_SYSTEM_PROMPT_GLOB_GREP_SUPPLEMENT = (
14
- "\n- glob: find files/directories by pattern\n"
15
- "- grep: search file contents using ripgrep (rg)"
16
- )