deepagents 0.2.6__py3-none-any.whl → 0.2.7__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,11 @@
1
1
  """Middleware for the DeepAgent."""
2
2
 
3
3
  from deepagents.middleware.filesystem import FilesystemMiddleware
4
- from deepagents.middleware.resumable_shell import ResumableShellToolMiddleware
5
4
  from deepagents.middleware.subagents import CompiledSubAgent, SubAgent, SubAgentMiddleware
6
5
 
7
6
  __all__ = [
8
7
  "CompiledSubAgent",
9
8
  "FilesystemMiddleware",
10
- "ResumableShellToolMiddleware",
11
9
  "SubAgent",
12
10
  "SubAgentMiddleware",
13
11
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepagents
3
- Version: 0.2.6
3
+ Version: 0.2.7
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
  Project-URL: Homepage, https://docs.langchain.com/oss/python/deepagents/overview
@@ -8,12 +8,11 @@ deepagents/backends/sandbox.py,sha256=JueMe_2cZcA359JIqIi8kDUkmdtevC4VbKHw-fBPOW
8
8
  deepagents/backends/state.py,sha256=ST_tUExPxArJaA3U8vc1dyzxuYl2BQH-HU7P0eu_Ty8,6518
9
9
  deepagents/backends/store.py,sha256=f2LVSl65Dg-BZl-cY3pl3RqrUJCBMBm2kuAzZEODwsE,13098
10
10
  deepagents/backends/utils.py,sha256=Iyk2jW-gfoLvMnz-W_2FRCoJW_j3r1zoumU9iww-jd0,13973
11
- deepagents/middleware/__init__.py,sha256=x7UHqGcrKlhzORNdChPvnUwa_PIJCbFUHY6zTKVfloI,418
11
+ deepagents/middleware/__init__.py,sha256=_OGIHcHZ2pRD0gzUBS7R48agwI6P7-FCBKBgjyaWlsg,303
12
12
  deepagents/middleware/filesystem.py,sha256=3PAetXqWy0i9bE6moM0FDZAEmjMm_M48B4AWWYl4Luk,37271
13
13
  deepagents/middleware/patch_tool_calls.py,sha256=PdNhxPaQqwnFkhEAZEE2kEzadTNAOO3_iJRA30WqpGE,1981
14
- deepagents/middleware/resumable_shell.py,sha256=KjhafjKu28Nf_8pDmSk_aWRK7pgkXZoubvWQljIEv3w,3382
15
14
  deepagents/middleware/subagents.py,sha256=RbNpWLXC0Bhr0nUIs40whybNnzNkhxG9Fie7QKsICRk,23748
16
- deepagents-0.2.6.dist-info/METADATA,sha256=gcNhcchWORoY_wyqYv8xU1lvvYccmOhuVDZIYTubNYI,18887
17
- deepagents-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- deepagents-0.2.6.dist-info/top_level.txt,sha256=drAzchOzPNePwpb3_pbPuvLuayXkN7SNqeIKMBWJoAo,11
19
- deepagents-0.2.6.dist-info/RECORD,,
15
+ deepagents-0.2.7.dist-info/METADATA,sha256=H5FgpjWX5qzV5uHcpm0ba4F1Jwtw_Kvj79U9mdUR3Os,18887
16
+ deepagents-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ deepagents-0.2.7.dist-info/top_level.txt,sha256=drAzchOzPNePwpb3_pbPuvLuayXkN7SNqeIKMBWJoAo,11
18
+ deepagents-0.2.7.dist-info/RECORD,,
@@ -1,86 +0,0 @@
1
- """Shell tool middleware that survives HITL pauses."""
2
-
3
- from __future__ import annotations
4
-
5
- from collections.abc import Awaitable, Callable
6
- from typing import Any, cast
7
-
8
- from langchain.agents.middleware.shell_tool import (
9
- ShellToolMiddleware,
10
- ShellToolState,
11
- _PersistentShellTool,
12
- _SessionResources,
13
- )
14
- from langchain.agents.middleware.types import AgentState
15
- from langchain.tools.tool_node import ToolCallRequest
16
- from langchain_core.messages import ToolMessage
17
- from langgraph.types import Command
18
-
19
-
20
- class ResumableShellToolMiddleware(ShellToolMiddleware):
21
- """Shell middleware that recreates session resources after human interrupts.
22
-
23
- ``ShellToolMiddleware`` stores its session handle in middleware state using an
24
- ``UntrackedValue``. When a run pauses for human approval, that attribute is not
25
- checkpointed. Upon resuming, LangGraph restores the state without the shell
26
- resources, so the next tool execution fails with
27
- ``Shell session resources are unavailable``.
28
-
29
- This subclass lazily recreates the shell session the first time a resumed run
30
- touches the shell tool again and only performs shutdown when a session is
31
- actually active. This keeps behaviour identical for uninterrupted runs while
32
- allowing HITL pauses to succeed.
33
- """
34
-
35
- def wrap_tool_call(
36
- self,
37
- request: ToolCallRequest,
38
- handler: Callable[[ToolCallRequest], ToolMessage | Command],
39
- ) -> ToolMessage | Command:
40
- if isinstance(request.tool, _PersistentShellTool):
41
- resources = self._get_or_create_resources(request.state)
42
- return self._run_shell_tool(
43
- resources,
44
- request.tool_call["args"],
45
- tool_call_id=request.tool_call.get("id"),
46
- )
47
- return super().wrap_tool_call(request, handler)
48
-
49
- async def awrap_tool_call(
50
- self,
51
- request: ToolCallRequest,
52
- handler: Callable[[ToolCallRequest], Awaitable[ToolMessage | Command]],
53
- ) -> ToolMessage | Command:
54
- if isinstance(request.tool, _PersistentShellTool):
55
- resources = self._get_or_create_resources(request.state)
56
- return self._run_shell_tool(
57
- resources,
58
- request.tool_call["args"],
59
- tool_call_id=request.tool_call.get("id"),
60
- )
61
- return await super().awrap_tool_call(request, handler)
62
-
63
- def after_agent(self, state: ShellToolState, runtime) -> None: # type: ignore[override]
64
- if self._has_resources(state):
65
- super().after_agent(state, runtime)
66
-
67
- async def aafter_agent(self, state: ShellToolState, runtime) -> None: # type: ignore[override]
68
- if self._has_resources(state):
69
- await super().aafter_agent(state, runtime)
70
-
71
- @staticmethod
72
- def _has_resources(state: AgentState) -> bool:
73
- resources = state.get("shell_session_resources")
74
- return isinstance(resources, _SessionResources)
75
-
76
- def _get_or_create_resources(self, state: AgentState) -> _SessionResources:
77
- resources = state.get("shell_session_resources")
78
- if isinstance(resources, _SessionResources):
79
- return resources
80
-
81
- new_resources = self._create_resources()
82
- cast("dict[str, Any]", state)["shell_session_resources"] = new_resources
83
- return new_resources
84
-
85
-
86
- __all__ = ["ResumableShellToolMiddleware"]