deepagents 0.2.0__py3-none-any.whl → 0.2.1__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.
@@ -1,13 +1,10 @@
1
1
  """CompositeBackend: Route operations to different backends based on path prefix."""
2
2
 
3
- from typing import Any, Literal, Optional, TYPE_CHECKING
3
+ from typing import Optional
4
4
 
5
- from langchain.tools import ToolRuntime
6
-
7
- from deepagents.backends.protocol import BackendProtocol, BackendFactory, WriteResult, EditResult
5
+ from deepagents.backends.protocol import BackendProtocol, WriteResult, EditResult
8
6
  from deepagents.backends.state import StateBackend
9
7
  from deepagents.backends.utils import FileInfo, GrepMatch
10
- from deepagents.backends.protocol import BackendFactory
11
8
 
12
9
 
13
10
  class CompositeBackend:
@@ -48,13 +45,14 @@ class CompositeBackend:
48
45
  return self.default, key
49
46
 
50
47
  def ls_info(self, path: str) -> list[FileInfo]:
51
- """List files from backends, with appropriate prefixes.
52
-
48
+ """List files and directories in the specified directory (non-recursive).
49
+
53
50
  Args:
54
51
  path: Absolute path to directory.
55
-
52
+
56
53
  Returns:
57
- List of FileInfo-like dicts with route prefixes added.
54
+ List of FileInfo-like dicts with route prefixes added, for files and directories directly in the directory.
55
+ Directories have a trailing / in their path and is_dir=True.
58
56
  """
59
57
  # Check if path matches a specific route
60
58
  for route_prefix, backend in self.sorted_routes:
@@ -75,11 +73,14 @@ class CompositeBackend:
75
73
  results: list[FileInfo] = []
76
74
  results.extend(self.default.ls_info(path))
77
75
  for route_prefix, backend in self.sorted_routes:
78
- infos = backend.ls_info("/")
79
- for fi in infos:
80
- fi = dict(fi)
81
- fi["path"] = f"{route_prefix[:-1]}{fi['path']}"
82
- results.append(fi)
76
+ # Add the route itself as a directory (e.g., /memories/)
77
+ results.append({
78
+ "path": route_prefix,
79
+ "is_dir": True,
80
+ "size": 0,
81
+ "modified_at": "",
82
+ })
83
+
83
84
  results.sort(key=lambda x: x.get("path", ""))
84
85
  return results
85
86
 
@@ -13,16 +13,12 @@ import json
13
13
  import subprocess
14
14
  from datetime import datetime
15
15
  from pathlib import Path
16
- from typing import Any, Optional, TYPE_CHECKING
17
-
18
- if TYPE_CHECKING:
19
- from langchain.tools import ToolRuntime
16
+ from typing import Optional
20
17
 
21
18
  from .utils import (
22
19
  check_empty_content,
23
20
  format_content_with_line_numbers,
24
21
  perform_string_replacement,
25
- truncate_if_too_long,
26
22
  )
27
23
  import wcmatch.glob as wcglob
28
24
  from deepagents.backends.utils import FileInfo, GrepMatch
@@ -51,7 +47,7 @@ class FilesystemBackend:
51
47
  all file paths will be resolved relative to this directory.
52
48
  If not provided, uses the current working directory.
53
49
  """
54
- self.cwd = Path(root_dir) if root_dir else Path.cwd()
50
+ self.cwd = Path(root_dir).resolve() if root_dir else Path.cwd()
55
51
  self.virtual_mode = virtual_mode
56
52
  self.max_file_size_bytes = max_file_size_mb * 1024 * 1024
57
53
 
@@ -77,7 +73,7 @@ class FilesystemBackend:
77
73
  try:
78
74
  full.relative_to(self.cwd)
79
75
  except ValueError:
80
- raise ValueError(f"Path outside root directory: {key}") from None
76
+ raise ValueError(f"Path:{full} outside root directory: {self.cwd}") from None
81
77
  return full
82
78
 
83
79
  path = Path(key)
@@ -86,13 +82,14 @@ class FilesystemBackend:
86
82
  return (self.cwd / path).resolve()
87
83
 
88
84
  def ls_info(self, path: str) -> list[FileInfo]:
89
- """List files from filesystem.
85
+ """List files and directories in the specified directory (non-recursive).
90
86
 
91
87
  Args:
92
88
  path: Absolute directory path to list files from.
93
-
89
+
94
90
  Returns:
95
- List of FileInfo-like dicts.
91
+ List of FileInfo-like dicts for files and directories directly in the directory.
92
+ Directories have a trailing / in their path and is_dir=True.
96
93
  """
97
94
  dir_path = self._resolve_path(path)
98
95
  if not dir_path.exists() or not dir_path.is_dir():
@@ -105,18 +102,22 @@ class FilesystemBackend:
105
102
  if not cwd_str.endswith("/"):
106
103
  cwd_str += "/"
107
104
 
108
- # Walk the directory tree
105
+ # List only direct children (non-recursive)
109
106
  try:
110
- for path in dir_path.rglob("*"):
107
+ for child_path in dir_path.iterdir():
111
108
  try:
112
- is_file = path.is_file()
109
+ is_file = child_path.is_file()
110
+ is_dir = child_path.is_dir()
113
111
  except OSError:
114
112
  continue
115
- if is_file:
116
- abs_path = str(path)
117
- if not self.virtual_mode:
113
+
114
+ abs_path = str(child_path)
115
+
116
+ if not self.virtual_mode:
117
+ # Non-virtual mode: use absolute paths
118
+ if is_file:
118
119
  try:
119
- st = path.stat()
120
+ st = child_path.stat()
120
121
  results.append({
121
122
  "path": abs_path,
122
123
  "is_dir": False,
@@ -125,8 +126,19 @@ class FilesystemBackend:
125
126
  })
126
127
  except OSError:
127
128
  results.append({"path": abs_path, "is_dir": False})
128
- continue
129
- # Strip the cwd prefix if present
129
+ elif is_dir:
130
+ try:
131
+ st = child_path.stat()
132
+ results.append({
133
+ "path": abs_path + "/",
134
+ "is_dir": True,
135
+ "size": 0,
136
+ "modified_at": datetime.fromtimestamp(st.st_mtime).isoformat(),
137
+ })
138
+ except OSError:
139
+ results.append({"path": abs_path + "/", "is_dir": True})
140
+ else:
141
+ # Virtual mode: strip cwd prefix
130
142
  if abs_path.startswith(cwd_str):
131
143
  relative_path = abs_path[len(cwd_str):]
132
144
  elif abs_path.startswith(str(self.cwd)):
@@ -137,16 +149,29 @@ class FilesystemBackend:
137
149
  relative_path = abs_path
138
150
 
139
151
  virt_path = "/" + relative_path
140
- try:
141
- st = path.stat()
142
- results.append({
143
- "path": virt_path,
144
- "is_dir": False,
145
- "size": int(st.st_size),
146
- "modified_at": datetime.fromtimestamp(st.st_mtime).isoformat(),
147
- })
148
- except OSError:
149
- results.append({"path": virt_path, "is_dir": False})
152
+
153
+ if is_file:
154
+ try:
155
+ st = child_path.stat()
156
+ results.append({
157
+ "path": virt_path,
158
+ "is_dir": False,
159
+ "size": int(st.st_size),
160
+ "modified_at": datetime.fromtimestamp(st.st_mtime).isoformat(),
161
+ })
162
+ except OSError:
163
+ results.append({"path": virt_path, "is_dir": False})
164
+ elif is_dir:
165
+ try:
166
+ st = child_path.stat()
167
+ results.append({
168
+ "path": virt_path + "/",
169
+ "is_dir": True,
170
+ "size": 0,
171
+ "modified_at": datetime.fromtimestamp(st.st_mtime).isoformat(),
172
+ })
173
+ except OSError:
174
+ results.append({"path": virt_path + "/", "is_dir": True})
150
175
  except (OSError, PermissionError):
151
176
  pass
152
177
 
@@ -40,19 +40,38 @@ class StateBackend:
40
40
  self.runtime = runtime
41
41
 
42
42
  def ls_info(self, path: str) -> list[FileInfo]:
43
- """List files from state.
44
-
43
+ """List files and directories in the specified directory (non-recursive).
44
+
45
45
  Args:
46
46
  path: Absolute path to directory.
47
-
47
+
48
48
  Returns:
49
- List of FileInfo-like dicts.
49
+ List of FileInfo-like dicts for files and directories directly in the directory.
50
+ Directories have a trailing / in their path and is_dir=True.
50
51
  """
51
52
  files = self.runtime.state.get("files", {})
52
53
  infos: list[FileInfo] = []
54
+ subdirs: set[str] = set()
55
+
56
+ # Normalize path to have trailing slash for proper prefix matching
57
+ normalized_path = path if path.endswith("/") else path + "/"
58
+
53
59
  for k, fd in files.items():
54
- if not k.startswith(path):
60
+ # Check if file is in the specified directory or a subdirectory
61
+ if not k.startswith(normalized_path):
62
+ continue
63
+
64
+ # Get the relative path after the directory
65
+ relative = k[len(normalized_path):]
66
+
67
+ # If relative path contains '/', it's in a subdirectory
68
+ if "/" in relative:
69
+ # Extract the immediate subdirectory name
70
+ subdir_name = relative.split("/")[0]
71
+ subdirs.add(normalized_path + subdir_name + "/")
55
72
  continue
73
+
74
+ # This is a file directly in the current directory
56
75
  size = len("\n".join(fd.get("content", [])))
57
76
  infos.append({
58
77
  "path": k,
@@ -60,6 +79,16 @@ class StateBackend:
60
79
  "size": int(size),
61
80
  "modified_at": fd.get("modified_at", ""),
62
81
  })
82
+
83
+ # Add directories to the results
84
+ for subdir in sorted(subdirs):
85
+ infos.append({
86
+ "path": subdir,
87
+ "is_dir": True,
88
+ "size": 0,
89
+ "modified_at": "",
90
+ })
91
+
63
92
  infos.sort(key=lambda x: x.get("path", ""))
64
93
  return infos
65
94
 
@@ -179,24 +179,43 @@ class StoreBackend:
179
179
  return all_items
180
180
 
181
181
  def ls_info(self, path: str) -> list[FileInfo]:
182
- """List files from store.
183
-
182
+ """List files and directories in the specified directory (non-recursive).
183
+
184
184
  Args:
185
185
  path: Absolute path to directory.
186
-
186
+
187
187
  Returns:
188
- List of FileInfo-like dicts.
188
+ List of FileInfo-like dicts for files and directories directly in the directory.
189
+ Directories have a trailing / in their path and is_dir=True.
189
190
  """
190
191
  store = self._get_store()
191
192
  namespace = self._get_namespace()
192
-
193
+
193
194
  # Retrieve all items and filter by path prefix locally to avoid
194
195
  # coupling to store-specific filter semantics
195
196
  items = self._search_store_paginated(store, namespace)
196
197
  infos: list[FileInfo] = []
198
+ subdirs: set[str] = set()
199
+
200
+ # Normalize path to have trailing slash for proper prefix matching
201
+ normalized_path = path if path.endswith("/") else path + "/"
202
+
197
203
  for item in items:
198
- if not str(item.key).startswith(path):
204
+ # Check if file is in the specified directory or a subdirectory
205
+ if not str(item.key).startswith(normalized_path):
199
206
  continue
207
+
208
+ # Get the relative path after the directory
209
+ relative = str(item.key)[len(normalized_path):]
210
+
211
+ # If relative path contains '/', it's in a subdirectory
212
+ if "/" in relative:
213
+ # Extract the immediate subdirectory name
214
+ subdir_name = relative.split("/")[0]
215
+ subdirs.add(normalized_path + subdir_name + "/")
216
+ continue
217
+
218
+ # This is a file directly in the current directory
200
219
  try:
201
220
  fd = self._convert_store_item_to_file_data(item)
202
221
  except ValueError:
@@ -208,6 +227,16 @@ class StoreBackend:
208
227
  "size": int(size),
209
228
  "modified_at": fd.get("modified_at", ""),
210
229
  })
230
+
231
+ # Add directories to the results
232
+ for subdir in sorted(subdirs):
233
+ infos.append({
234
+ "path": subdir,
235
+ "is_dir": True,
236
+ "size": 0,
237
+ "modified_at": "",
238
+ })
239
+
211
240
  infos.sort(key=lambda x: x.get("path", ""))
212
241
  return infos
213
242
 
@@ -12,7 +12,7 @@ from pathlib import Path
12
12
  from typing import Any, Literal, TypedDict, List, Dict
13
13
 
14
14
  EMPTY_CONTENT_WARNING = "System reminder: File exists but has empty contents"
15
- MAX_LINE_LENGTH = 2000
15
+ MAX_LINE_LENGTH = 10000
16
16
  LINE_NUMBER_WIDTH = 6
17
17
  TOOL_RESULT_TOKEN_LIMIT = 20000 # Same threshold as eviction
18
18
  TRUNCATION_GUIDANCE = "... [results truncated, try being more specific with your parameters]"
@@ -37,18 +37,29 @@ class GrepMatch(TypedDict):
37
37
  text: str
38
38
 
39
39
 
40
+ def sanitize_tool_call_id(tool_call_id: str) -> str:
41
+ """Sanitize tool_call_id to prevent path traversal and separator issues.
42
+
43
+ Replaces dangerous characters (., /, \) with underscores.
44
+ """
45
+ sanitized = tool_call_id.replace(".", "_").replace("/", "_").replace("\\", "_")
46
+ return sanitized
47
+
48
+
40
49
  def format_content_with_line_numbers(
41
50
  content: str | list[str],
42
51
  start_line: int = 1,
43
52
  ) -> str:
44
53
  """Format file content with line numbers (cat -n style).
45
-
54
+
55
+ Chunks lines longer than MAX_LINE_LENGTH with continuation markers (e.g., 5.1, 5.2).
56
+
46
57
  Args:
47
58
  content: File content as string or list of lines
48
59
  start_line: Starting line number (default: 1)
49
-
60
+
50
61
  Returns:
51
- Formatted content with line numbers
62
+ Formatted content with line numbers and continuation markers
52
63
  """
53
64
  if isinstance(content, str):
54
65
  lines = content.split("\n")
@@ -56,11 +67,29 @@ def format_content_with_line_numbers(
56
67
  lines = lines[:-1]
57
68
  else:
58
69
  lines = content
59
-
60
- return "\n".join(
61
- f"{i + start_line:{LINE_NUMBER_WIDTH}d}\t{line[:MAX_LINE_LENGTH]}"
62
- for i, line in enumerate(lines)
63
- )
70
+
71
+ result_lines = []
72
+ for i, line in enumerate(lines):
73
+ line_num = i + start_line
74
+
75
+ if len(line) <= MAX_LINE_LENGTH:
76
+ result_lines.append(f"{line_num:{LINE_NUMBER_WIDTH}d}\t{line}")
77
+ else:
78
+ # Split long line into chunks with continuation markers
79
+ num_chunks = (len(line) + MAX_LINE_LENGTH - 1) // MAX_LINE_LENGTH
80
+ for chunk_idx in range(num_chunks):
81
+ start = chunk_idx * MAX_LINE_LENGTH
82
+ end = min(start + MAX_LINE_LENGTH, len(line))
83
+ chunk = line[start:end]
84
+ if chunk_idx == 0:
85
+ # First chunk: use normal line number
86
+ result_lines.append(f"{line_num:{LINE_NUMBER_WIDTH}d}\t{chunk}")
87
+ else:
88
+ # Continuation chunks: use decimal notation (e.g., 5.1, 5.2)
89
+ continuation_marker = f"{line_num}.{chunk_idx}"
90
+ result_lines.append(f"{continuation_marker:>{LINE_NUMBER_WIDTH}}\t{chunk}")
91
+
92
+ return "\n".join(result_lines)
64
93
 
65
94
 
66
95
  def check_empty_content(content: str) -> str | None:
@@ -91,18 +120,17 @@ def file_data_to_string(file_data: dict[str, Any]) -> str:
91
120
 
92
121
  def create_file_data(content: str, created_at: str | None = None) -> dict[str, Any]:
93
122
  """Create a FileData object with timestamps.
94
-
123
+
95
124
  Args:
96
125
  content: File content as string
97
126
  created_at: Optional creation timestamp (ISO format)
98
-
127
+
99
128
  Returns:
100
129
  FileData dict with content and timestamps
101
130
  """
102
131
  lines = content.split("\n") if isinstance(content, str) else content
103
- lines = [line[i:i+MAX_LINE_LENGTH] for line in lines for i in range(0, len(line) or 1, MAX_LINE_LENGTH)]
104
132
  now = datetime.now(UTC).isoformat()
105
-
133
+
106
134
  return {
107
135
  "content": lines,
108
136
  "created_at": created_at or now,
@@ -112,18 +140,17 @@ def create_file_data(content: str, created_at: str | None = None) -> dict[str, A
112
140
 
113
141
  def update_file_data(file_data: dict[str, Any], content: str) -> dict[str, Any]:
114
142
  """Update FileData with new content, preserving creation timestamp.
115
-
143
+
116
144
  Args:
117
145
  file_data: Existing FileData dict
118
146
  content: New content as string
119
-
147
+
120
148
  Returns:
121
149
  Updated FileData dict
122
150
  """
123
151
  lines = content.split("\n") if isinstance(content, str) else content
124
- lines = [line[i:i+MAX_LINE_LENGTH] for line in lines for i in range(0, len(line) or 1, MAX_LINE_LENGTH)]
125
152
  now = datetime.now(UTC).isoformat()
126
-
153
+
127
154
  return {
128
155
  "content": lines,
129
156
  "created_at": file_data["created_at"],
@@ -24,11 +24,11 @@ from typing_extensions import TypedDict
24
24
  from deepagents.backends.protocol import BackendProtocol, BackendFactory, WriteResult, EditResult
25
25
  from deepagents.backends import StateBackend
26
26
  from deepagents.backends.utils import (
27
- create_file_data,
28
27
  update_file_data,
29
28
  format_content_with_line_numbers,
30
29
  format_grep_matches,
31
30
  truncate_if_too_long,
31
+ sanitize_tool_call_id,
32
32
  )
33
33
 
34
34
  EMPTY_CONTENT_WARNING = "System reminder: File exists but has empty contents"
@@ -227,6 +227,15 @@ All file paths must start with a /.
227
227
 
228
228
 
229
229
  def _get_backend(backend: BACKEND_TYPES, runtime: ToolRuntime) -> BackendProtocol:
230
+ """Get the resolved backend instance from backend or factory.
231
+
232
+ Args:
233
+ backend: Backend instance or factory function.
234
+ runtime: The tool runtime context.
235
+
236
+ Returns:
237
+ Resolved backend instance.
238
+ """
230
239
  if callable(backend):
231
240
  return backend(runtime)
232
241
  return backend
@@ -532,6 +541,19 @@ class FilesystemMiddleware(AgentMiddleware):
532
541
 
533
542
  self.tools = _get_filesystem_tools(self.backend, custom_tool_descriptions)
534
543
 
544
+ def _get_backend(self, runtime: ToolRuntime) -> BackendProtocol:
545
+ """Get the resolved backend instance from backend or factory.
546
+
547
+ Args:
548
+ runtime: The tool runtime context.
549
+
550
+ Returns:
551
+ Resolved backend instance.
552
+ """
553
+ if callable(self.backend):
554
+ return self.backend(runtime)
555
+ return self.backend
556
+
535
557
  def wrap_model_call(
536
558
  self,
537
559
  request: ModelRequest,
@@ -568,54 +590,70 @@ class FilesystemMiddleware(AgentMiddleware):
568
590
  request.system_prompt = request.system_prompt + "\n\n" + self.system_prompt if request.system_prompt else self.system_prompt
569
591
  return await handler(request)
570
592
 
571
- def _intercept_large_tool_result(self, tool_result: ToolMessage | Command) -> ToolMessage | Command:
593
+ def _process_large_message(
594
+ self,
595
+ message: ToolMessage,
596
+ resolved_backend: BackendProtocol,
597
+ ) -> tuple[ToolMessage, dict[str, FileData] | None]:
598
+ content = message.content
599
+ if not isinstance(content, str) or len(content) <= 4 * self.tool_token_limit_before_evict:
600
+ return message, None
601
+
602
+ sanitized_id = sanitize_tool_call_id(message.tool_call_id)
603
+ file_path = f"/large_tool_results/{sanitized_id}"
604
+ result = resolved_backend.write(file_path, content)
605
+ if result.error:
606
+ return message, None
607
+ content_sample = format_content_with_line_numbers(content.splitlines()[:10], start_line=1)
608
+ processed_message = ToolMessage(
609
+ TOO_LARGE_TOOL_MSG.format(
610
+ tool_call_id=message.tool_call_id,
611
+ file_path=file_path,
612
+ content_sample=content_sample,
613
+ ),
614
+ tool_call_id=message.tool_call_id,
615
+ )
616
+ return processed_message, result.files_update
617
+
618
+ def _intercept_large_tool_result(self, tool_result: ToolMessage | Command, runtime: ToolRuntime) -> ToolMessage | Command:
572
619
  if isinstance(tool_result, ToolMessage) and isinstance(tool_result.content, str):
573
- content = tool_result.content
574
- if self.tool_token_limit_before_evict and len(content) > 4 * self.tool_token_limit_before_evict:
575
- file_path = f"/large_tool_results/{tool_result.tool_call_id}"
576
- file_data = create_file_data(content)
577
- state_update = {
578
- "messages": [
579
- ToolMessage(
580
- TOO_LARGE_TOOL_MSG.format(
581
- tool_call_id=tool_result.tool_call_id,
582
- file_path=file_path,
583
- content_sample=format_content_with_line_numbers(file_data["content"][:10], start_line=1),
584
- ),
585
- tool_call_id=tool_result.tool_call_id,
586
- )
587
- ],
588
- "files": {file_path: file_data},
589
- }
590
- return Command(update=state_update)
620
+ if not (self.tool_token_limit_before_evict and
621
+ len(tool_result.content) > 4 * self.tool_token_limit_before_evict):
622
+ return tool_result
623
+ resolved_backend = self._get_backend(runtime)
624
+ processed_message, files_update = self._process_large_message(
625
+ tool_result,
626
+ resolved_backend,
627
+ )
628
+ return (Command(update={
629
+ "files": files_update,
630
+ "messages": [processed_message],
631
+ }) if files_update is not None else processed_message)
632
+
591
633
  elif isinstance(tool_result, Command):
592
634
  update = tool_result.update
593
635
  if update is None:
594
636
  return tool_result
595
- message_updates = update.get("messages", [])
596
- file_updates = update.get("files", {})
597
-
598
- edited_message_updates = []
599
- for message in message_updates:
600
- if self.tool_token_limit_before_evict and isinstance(message, ToolMessage) and isinstance(message.content, str):
601
- content = message.content
602
- if len(content) > 4 * self.tool_token_limit_before_evict:
603
- file_path = f"/large_tool_results/{message.tool_call_id}"
604
- file_data = create_file_data(content)
605
- edited_message_updates.append(
606
- ToolMessage(
607
- TOO_LARGE_TOOL_MSG.format(
608
- tool_call_id=message.tool_call_id,
609
- file_path=file_path,
610
- content_sample=format_content_with_line_numbers(file_data["content"][:10], start_line=1),
611
- ),
612
- tool_call_id=message.tool_call_id,
613
- )
614
- )
615
- file_updates[file_path] = file_data
616
- continue
617
- edited_message_updates.append(message)
618
- return Command(update={**update, "messages": edited_message_updates, "files": file_updates})
637
+ command_messages = update.get("messages", [])
638
+ accumulated_file_updates = dict(update.get("files", {}))
639
+ resolved_backend = self._get_backend(runtime)
640
+ processed_messages = []
641
+ for message in command_messages:
642
+ if not (self.tool_token_limit_before_evict and
643
+ isinstance(message, ToolMessage) and
644
+ isinstance(message.content, str) and
645
+ len(message.content) > 4 * self.tool_token_limit_before_evict):
646
+ processed_messages.append(message)
647
+ continue
648
+ processed_message, files_update = self._process_large_message(
649
+ message,
650
+ resolved_backend,
651
+ )
652
+ processed_messages.append(processed_message)
653
+ if files_update is not None:
654
+ accumulated_file_updates.update(files_update)
655
+ return Command(update={**update, "messages": processed_messages, "files": accumulated_file_updates})
656
+
619
657
  return tool_result
620
658
 
621
659
  def wrap_tool_call(
@@ -636,7 +674,7 @@ class FilesystemMiddleware(AgentMiddleware):
636
674
  return handler(request)
637
675
 
638
676
  tool_result = handler(request)
639
- return self._intercept_large_tool_result(tool_result)
677
+ return self._intercept_large_tool_result(tool_result, request.runtime)
640
678
 
641
679
  async def awrap_tool_call(
642
680
  self,
@@ -656,4 +694,4 @@ class FilesystemMiddleware(AgentMiddleware):
656
694
  return await handler(request)
657
695
 
658
696
  tool_result = await handler(request)
659
- return self._intercept_large_tool_result(tool_result)
697
+ return self._intercept_large_tool_result(tool_result, request.runtime)
@@ -3,9 +3,9 @@
3
3
  from typing import Any
4
4
 
5
5
  from langchain.agents.middleware import AgentMiddleware, AgentState
6
- from langchain_core.messages import RemoveMessage, ToolMessage
7
- from langgraph.graph.message import REMOVE_ALL_MESSAGES
6
+ from langchain_core.messages import ToolMessage
8
7
  from langgraph.runtime import Runtime
8
+ from langgraph.types import Overwrite
9
9
 
10
10
 
11
11
  class PatchToolCallsMiddleware(AgentMiddleware):
@@ -41,4 +41,4 @@ class PatchToolCallsMiddleware(AgentMiddleware):
41
41
  )
42
42
  )
43
43
 
44
- return {"messages": [RemoveMessage(id=REMOVE_ALL_MESSAGES), *patched_messages]}
44
+ return {"messages": Overwrite(patched_messages)}
@@ -273,7 +273,6 @@ def _get_subagents(
273
273
  system_prompt=agent_["system_prompt"],
274
274
  tools=_tools,
275
275
  middleware=_middleware,
276
- checkpointer=False,
277
276
  )
278
277
  return agents, subagent_descriptions
279
278
 
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepagents
3
- Version: 0.2.0
3
+ Version: 0.2.1
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
9
  Requires-Dist: langchain-anthropic<2.0.0,>=1.0.0
10
- Requires-Dist: langchain<2.0.0,>=1.0.0
10
+ Requires-Dist: langchain<2.0.0,>=1.0.2
11
11
  Requires-Dist: langchain-core<2.0.0,>=1.0.0
12
12
  Requires-Dist: wcmatch
13
13
  Provides-Extra: dev
@@ -0,0 +1,18 @@
1
+ deepagents/__init__.py,sha256=9BVNn4lfF5N8l2KY8Ttxi82zO609I-fGqoSIF7DAxiU,342
2
+ deepagents/graph.py,sha256=6hXBwvQDwbUtiF8Tgwf1jbvRHwJGLEJq89fy-DpVez0,6106
3
+ deepagents/backends/__init__.py,sha256=qb2dt2axTQsh8BGqW2EDyJq8GazC8_z87MQYo_VXhBw,457
4
+ deepagents/backends/composite.py,sha256=kyW0H346s1XIxNkRHRbDF9SSR-zeigeEFO8bizn5iFg,8555
5
+ deepagents/backends/filesystem.py,sha256=U9Tmf8BDTqKbw-gQjJkJOYG1nXQo9FhxyfzN97W9Z_8,18470
6
+ deepagents/backends/protocol.py,sha256=fwqJa_Ec6F4BoNYz0bcPHL_fiKksxw2RoyA6x5wr7dc,4181
7
+ deepagents/backends/state.py,sha256=BxMNm1kDpxtgzIzpuF78h1NuYh9VIpXqnUbbETGe4Y4,6584
8
+ deepagents/backends/store.py,sha256=VsPSj6ayABPjkKiN6CcvOGm7YCWKuWP_ltJWvFJ1nF0,13358
9
+ deepagents/backends/utils.py,sha256=vQDMFMjf7pmfKqprpTlF7851FWmswZnMdLj-cezTsBk,14432
10
+ deepagents/middleware/__init__.py,sha256=J7372TNGR27OU4C3uuQMryHHpXOBjFV_4aEZ_AoQ6n0,284
11
+ deepagents/middleware/filesystem.py,sha256=jxtwma6xWE-EQeASs6rtnoiiLqb_HT4c-cxsLFquneE,27882
12
+ deepagents/middleware/patch_tool_calls.py,sha256=PdNhxPaQqwnFkhEAZEE2kEzadTNAOO3_iJRA30WqpGE,1981
13
+ deepagents/middleware/subagents.py,sha256=JxXwZvi41pBKKMguKlyVqwjCoydnZboWEgJGkWOCIY8,23503
14
+ deepagents-0.2.1.dist-info/licenses/LICENSE,sha256=c__BaxUCK69leo2yEKynf8lWndu8iwYwge1CbyqAe-E,1071
15
+ deepagents-0.2.1.dist-info/METADATA,sha256=kXdfjz1KdcYpKWWll_QpeRnFcYpZGnjNSuChET2dp48,18660
16
+ deepagents-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ deepagents-0.2.1.dist-info/top_level.txt,sha256=drAzchOzPNePwpb3_pbPuvLuayXkN7SNqeIKMBWJoAo,11
18
+ deepagents-0.2.1.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- deepagents/__init__.py,sha256=9BVNn4lfF5N8l2KY8Ttxi82zO609I-fGqoSIF7DAxiU,342
2
- deepagents/graph.py,sha256=6hXBwvQDwbUtiF8Tgwf1jbvRHwJGLEJq89fy-DpVez0,6106
3
- deepagents/backends/__init__.py,sha256=qb2dt2axTQsh8BGqW2EDyJq8GazC8_z87MQYo_VXhBw,457
4
- deepagents/backends/composite.py,sha256=1FLJQS2jAqeCwz-Zat4QQRLiklwgbKDZkkztZUJAgSA,8514
5
- deepagents/backends/filesystem.py,sha256=oq3oI9W5kfmEXItOqKIGHx_PTKxjQTDh8IqVuV5ZFzw,17067
6
- deepagents/backends/protocol.py,sha256=fwqJa_Ec6F4BoNYz0bcPHL_fiKksxw2RoyA6x5wr7dc,4181
7
- deepagents/backends/state.py,sha256=Mm2U5IcTDxvJMhG3K1HGODCW70Qseb2arjPe5JewnO0,5439
8
- deepagents/backends/store.py,sha256=NuxQK5znhbR5uz1PH6BfiWu9mGHWSk6TcKgb5ZuoJaM,12209
9
- deepagents/backends/utils.py,sha256=0VK5_NJbolZs4iPzB53I6kyFpDdjgxLYGl4ob8pKYyw,13347
10
- deepagents/middleware/__init__.py,sha256=J7372TNGR27OU4C3uuQMryHHpXOBjFV_4aEZ_AoQ6n0,284
11
- deepagents/middleware/filesystem.py,sha256=IggpI5ENGy5ykB4HCtTq0l5mM618eUDaFiLYArTUi94,26897
12
- deepagents/middleware/patch_tool_calls.py,sha256=Cu8rUpt1GjrYgfMvZG6wOowvnmFeYTCauOJhlltNPmo,2045
13
- deepagents/middleware/subagents.py,sha256=hYW0cJV36fryu67S3H70VnM3SessiOz_vm3gSScC4a4,23535
14
- deepagents-0.2.0.dist-info/licenses/LICENSE,sha256=c__BaxUCK69leo2yEKynf8lWndu8iwYwge1CbyqAe-E,1071
15
- deepagents-0.2.0.dist-info/METADATA,sha256=KrdEh98Ptx0WBE3L5bMqjBPyouCW7D3jazb566Vu4ZY,18660
16
- deepagents-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
- deepagents-0.2.0.dist-info/top_level.txt,sha256=drAzchOzPNePwpb3_pbPuvLuayXkN7SNqeIKMBWJoAo,11
18
- deepagents-0.2.0.dist-info/RECORD,,