deepagents 0.7.43__tar.gz → 0.7.45__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.7.43 → deepagents-0.7.45}/PKG-INFO +5 -5
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_version.py +1 -1
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/sandbox.py +2 -3
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/graph.py +45 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_blob_offload.py +99 -21
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/async_subagents.py +41 -3
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/filesystem.py +39 -17
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/skills.py +11 -16
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/summarization.py +13 -2
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/_builtin_profiles.py +4 -0
- deepagents-0.7.45/deepagents/profiles/harness/_fireworks_kimi_k3p1_pro.py +27 -0
- deepagents-0.7.45/deepagents/profiles/harness/_openai_gpt_6_1_sol.py +52 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents.egg-info/PKG-INFO +5 -5
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents.egg-info/SOURCES.txt +2 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents.egg-info/requires.txt +4 -4
- {deepagents-0.7.43 → deepagents-0.7.45}/pyproject.toml +6 -6
- {deepagents-0.7.43 → deepagents-0.7.45}/LICENSE +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/README.md +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_api/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_api/deprecation.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_excluded_middleware.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_models.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/_tools.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/_posix_process.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/_windows_process.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/composite.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/context_hub.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/filesystem.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/langsmith.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/local_shell.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/protocol.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/state.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/store.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/backends/utils.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_fs_interrupt.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_message_eviction.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_overflow_clip.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_parent_notifier.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_prompt_caching.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_skill_tools.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_state.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_tool_disclosure.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_tool_exclusion.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_utils.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/_video.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/memory.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/patch_tool_calls.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/permissions.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/rubric.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/subagents.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/middleware/unsupported_content.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/_keys.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_anthropic_haiku_4_5.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_anthropic_opus_4_7.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_anthropic_sonnet_4_6.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_nvidia_nemotron_3_ultra.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_openai_codex.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/harness_profiles.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/provider/__init__.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/provider/_nvidia.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/provider/_openai.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/provider/_openrouter.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/provider/provider_profiles.py +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents/py.typed +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents.egg-info/dependency_links.txt +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/deepagents.egg-info/top_level.txt +0 -0
- {deepagents-0.7.43 → deepagents-0.7.45}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepagents
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.45
|
|
4
4
|
Summary: Production-ready, extensible agent harness with a built-in filesystem and context management, sub-agent delegation, skills, and long-term memory.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Homepage, https://docs.langchain.com/oss/python/deepagents/overview
|
|
@@ -25,11 +25,11 @@ Requires-Python: <4.0,>=3.11
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: langchain<2.0.0,>=1.5.2
|
|
28
|
-
Requires-Dist: langchain-core<2.0.0,>=1.
|
|
29
|
-
Requires-Dist: langchain-anthropic<2.0.0,>=1.
|
|
28
|
+
Requires-Dist: langchain-core<2.0.0,>=1.9.0
|
|
29
|
+
Requires-Dist: langchain-anthropic<2.0.0,>=1.8.0
|
|
30
30
|
Requires-Dist: langchain-google-genai<5.0.0,>=4.4.3
|
|
31
|
-
Requires-Dist: langgraph<2.0.0,>=1.2.
|
|
32
|
-
Requires-Dist: langsmith>=0.16.
|
|
31
|
+
Requires-Dist: langgraph<2.0.0,>=1.2.25
|
|
32
|
+
Requires-Dist: langsmith>=0.16.7
|
|
33
33
|
Requires-Dist: packaging>=23.2
|
|
34
34
|
Requires-Dist: wcmatch>=11.0
|
|
35
35
|
Provides-Extra: aws
|
|
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
|
|
|
18
18
|
# uses it to keep `__version__` in sync with `pyproject.toml` on every release
|
|
19
19
|
# PR. Without it, `__version__` silently drifts behind the package version. See
|
|
20
20
|
# `.github/RELEASING.md` > Version Bumping.
|
|
21
|
-
__version__ = "0.7.
|
|
21
|
+
__version__ = "0.7.45" # x-release-please-version
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def _distribution_name(dist: Distribution) -> str:
|
|
@@ -1168,7 +1168,7 @@ def _glob_output_shortcut(result: ExecuteResponse, output: str, search_path: str
|
|
|
1168
1168
|
"""
|
|
1169
1169
|
if result.exit_code is not None and result.exit_code != 0:
|
|
1170
1170
|
detail = output[:200] if output else f"exit code {result.exit_code}"
|
|
1171
|
-
logger.
|
|
1171
|
+
logger.warning("Sandbox glob helper failed for path %r: %s", search_path, detail)
|
|
1172
1172
|
return GlobResult(matches=None, error=f"Path '{search_path}': glob helper failed: {detail}")
|
|
1173
1173
|
if not output:
|
|
1174
1174
|
return GlobResult(
|
|
@@ -1263,10 +1263,9 @@ def _parse_glob_output(result: ExecuteResponse, search_path: str) -> GlobResult:
|
|
|
1263
1263
|
payload[:200],
|
|
1264
1264
|
)
|
|
1265
1265
|
if error is not None:
|
|
1266
|
-
logger.error("Sandbox glob returned error %r for path %r", error, search_path)
|
|
1267
1266
|
return GlobResult(matches=None, error=f"Path '{search_path}': {error}")
|
|
1268
1267
|
if unparsed:
|
|
1269
|
-
logger.
|
|
1268
|
+
logger.warning(
|
|
1270
1269
|
"Sandbox glob emitted %d unparseable line(s) for path %r; first: %s",
|
|
1271
1270
|
len(unparsed),
|
|
1272
1271
|
search_path,
|
|
@@ -636,6 +636,51 @@ def create_deep_agent( # noqa: C901, PLR0912, PLR0915 # Complex graph assembly
|
|
|
636
636
|
uses a private (underscore-prefixed) name, collides with multiple
|
|
637
637
|
distinct middleware classes, or matches no entry in the assembled
|
|
638
638
|
stack.
|
|
639
|
+
|
|
640
|
+
Examples:
|
|
641
|
+
Given a chat `model` and a read-only `search` tool, configure middleware
|
|
642
|
+
to retry transient model failures and timeouts or connection errors from
|
|
643
|
+
`search`. Convert `ValueError` from tool execution into feedback the
|
|
644
|
+
model can act on; let other exceptions propagate.
|
|
645
|
+
|
|
646
|
+
```python
|
|
647
|
+
from langchain.agents.middleware import (
|
|
648
|
+
ModelRetryMiddleware,
|
|
649
|
+
ToolCallRequest,
|
|
650
|
+
ToolErrorMiddleware,
|
|
651
|
+
ToolRetryMiddleware,
|
|
652
|
+
)
|
|
653
|
+
|
|
654
|
+
from deepagents import create_deep_agent
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
def on_tool_error(exc: Exception, request: ToolCallRequest) -> str | None:
|
|
658
|
+
if isinstance(exc, ValueError):
|
|
659
|
+
return f"Check the input to `{request.tool_call['name']}` and try again."
|
|
660
|
+
return None
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
agent = create_deep_agent(
|
|
664
|
+
model=model,
|
|
665
|
+
tools=[search],
|
|
666
|
+
middleware=[
|
|
667
|
+
ModelRetryMiddleware(max_retries=3),
|
|
668
|
+
ToolErrorMiddleware(on_tool_error),
|
|
669
|
+
ToolRetryMiddleware(
|
|
670
|
+
max_retries=2,
|
|
671
|
+
tools=["search"],
|
|
672
|
+
retry_on=(TimeoutError, ConnectionError),
|
|
673
|
+
on_failure="error",
|
|
674
|
+
),
|
|
675
|
+
],
|
|
676
|
+
)
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
Put `ToolErrorMiddleware` before `ToolRetryMiddleware` and set
|
|
680
|
+
`on_failure="error"` so the error handler sees any exception the retry
|
|
681
|
+
middleware lets through. See the
|
|
682
|
+
[fault-tolerance guide](https://docs.langchain.com/oss/python/deepagents/fault-tolerance)
|
|
683
|
+
for more configuration options.
|
|
639
684
|
"""
|
|
640
685
|
# `DeepAgentState` is a `TypedDict`; TypedDicts disallow `issubclass`, so the
|
|
641
686
|
# subclass constraint on `state_schema` is enforced by typing alone and not
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
"""Content-addressed offload of inline human
|
|
1
|
+
"""Content-addressed offload of inline media in human messages and tool results.
|
|
2
2
|
|
|
3
3
|
Binary blocks are written to `{artifacts_root}/blobs/<sha256>` and replaced in
|
|
4
|
-
state with a
|
|
5
|
-
backend. Initial input checkpoints can still
|
|
4
|
+
state with a reference in the block's `extras`, under `deepagents_blob`. Model
|
|
5
|
+
requests are rehydrated from the backend. Initial input checkpoints can still
|
|
6
|
+
carry inline payloads.
|
|
7
|
+
|
|
8
|
+
To keep blobs somewhere other than the agent's default backend, route the
|
|
9
|
+
`blobs/` prefix to another backend with `CompositeBackend`.
|
|
6
10
|
"""
|
|
7
11
|
|
|
8
12
|
from __future__ import annotations
|
|
@@ -29,15 +33,26 @@ if TYPE_CHECKING:
|
|
|
29
33
|
logger = logging.getLogger(__name__)
|
|
30
34
|
|
|
31
35
|
_BLOB_REF_KEY: Final = "deepagents_blob"
|
|
32
|
-
"""
|
|
36
|
+
"""Key in a content block's `extras` holding the SHA-256 digest of an offloaded payload.
|
|
37
|
+
|
|
38
|
+
Stubs written before references moved to `extras` hold it at the top level of
|
|
39
|
+
the block; both are read.
|
|
40
|
+
"""
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
_EXTRAS_KEY: Final = "extras"
|
|
43
|
+
|
|
44
|
+
_MISSING_BLOB_TEXT: Final = (
|
|
45
|
+
"[Binary content from earlier in this conversation is no longer available. Re-read or regenerate it if you still need it.]"
|
|
46
|
+
)
|
|
35
47
|
|
|
36
48
|
_BLOB_PAYLOADS_KEY: Final = "_blob_payloads"
|
|
37
49
|
"""Private, untracked state key mapping digests to base64 payloads for the current run."""
|
|
38
50
|
|
|
39
51
|
_DIGEST_RE: Final = re.compile(r"[0-9a-f]{64}")
|
|
40
52
|
|
|
53
|
+
_DATA_URL_RE: Final = re.compile(r"data:([\w.+-]+/[\w.+-]+);base64,(.*)", re.DOTALL)
|
|
54
|
+
"""A base64 `data:` URL, capturing its MIME type and payload."""
|
|
55
|
+
|
|
41
56
|
_TOOL_BLOB_STORE: ContextVar[tuple[BackendProtocol, str] | None] = ContextVar("_tool_blob_store", default=None)
|
|
42
57
|
"""Request-scoped blob storage for tools that explicitly need portable media."""
|
|
43
58
|
|
|
@@ -57,6 +72,64 @@ def _blob_path(prefix: str, digest: str) -> str:
|
|
|
57
72
|
return f"{prefix}/{digest}"
|
|
58
73
|
|
|
59
74
|
|
|
75
|
+
def _inline_payload(block: Any) -> tuple[str, str | None] | None: # noqa: ANN401
|
|
76
|
+
"""Return a block's inline base64 payload, and the MIME type when it came from a `data:` URL.
|
|
77
|
+
|
|
78
|
+
Covers a standard block's `base64`, a standard block whose `url` is a `data:` URL,
|
|
79
|
+
and an OpenAI-style `image_url` block whose URL is one.
|
|
80
|
+
"""
|
|
81
|
+
if not isinstance(block, dict):
|
|
82
|
+
return None
|
|
83
|
+
payload = block.get("base64")
|
|
84
|
+
if isinstance(payload, str):
|
|
85
|
+
return payload, None
|
|
86
|
+
url = block.get("url")
|
|
87
|
+
image_url = block.get("image_url")
|
|
88
|
+
if block.get("type") == "image_url" and isinstance(image_url, dict):
|
|
89
|
+
url = image_url.get("url")
|
|
90
|
+
if isinstance(url, str) and (match := _DATA_URL_RE.fullmatch(url)):
|
|
91
|
+
return match[2], match[1]
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _with_ref(block: dict[str, Any], digest: str) -> dict[str, Any]:
|
|
96
|
+
extras = block.get(_EXTRAS_KEY)
|
|
97
|
+
extras = extras if isinstance(extras, dict) else {}
|
|
98
|
+
return block | {_EXTRAS_KEY: {**extras, _BLOB_REF_KEY: digest}}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _ref_holder(block: Any) -> dict[str, Any] | None: # noqa: ANN401
|
|
102
|
+
"""Return the dict holding a block's blob reference: its `extras`, or the block itself for a legacy stub."""
|
|
103
|
+
if not isinstance(block, dict):
|
|
104
|
+
return None
|
|
105
|
+
extras = block.get(_EXTRAS_KEY)
|
|
106
|
+
if isinstance(extras, dict) and _BLOB_REF_KEY in extras:
|
|
107
|
+
return extras
|
|
108
|
+
return block if _BLOB_REF_KEY in block else None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _without_ref(block: dict[str, Any]) -> dict[str, Any]:
|
|
112
|
+
"""Return `block` without its blob reference, dropping `extras` when nothing else is left in it."""
|
|
113
|
+
rest = {key: value for key, value in block.items() if key not in {_BLOB_REF_KEY, _EXTRAS_KEY}}
|
|
114
|
+
extras = block.get(_EXTRAS_KEY)
|
|
115
|
+
if isinstance(extras, dict):
|
|
116
|
+
extras = {key: value for key, value in extras.items() if key != _BLOB_REF_KEY}
|
|
117
|
+
if extras:
|
|
118
|
+
rest[_EXTRAS_KEY] = extras
|
|
119
|
+
return rest
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _stub_block(block: dict[str, Any], digest: str, data_url_mime: str | None) -> dict[str, Any]:
|
|
123
|
+
"""Return `block` with its inline payload replaced by a reference to `digest`."""
|
|
124
|
+
if data_url_mime is None:
|
|
125
|
+
return _with_ref({key: value for key, value in block.items() if key != "base64"}, digest)
|
|
126
|
+
if block.get("type") == "image_url":
|
|
127
|
+
return _with_ref({"type": "image", "mime_type": data_url_mime}, digest)
|
|
128
|
+
stub = {key: value for key, value in block.items() if key != "url"}
|
|
129
|
+
stub.setdefault("mime_type", data_url_mime)
|
|
130
|
+
return _with_ref(stub, digest)
|
|
131
|
+
|
|
132
|
+
|
|
60
133
|
def _pending_blobs(messages: Sequence[Any]) -> dict[str, tuple[str, bytes]]:
|
|
61
134
|
"""Map each inline base64 payload to its digest and decoded bytes."""
|
|
62
135
|
pending: dict[str, tuple[str, bytes]] = {}
|
|
@@ -64,9 +137,10 @@ def _pending_blobs(messages: Sequence[Any]) -> dict[str, tuple[str, bytes]]:
|
|
|
64
137
|
if not isinstance(message, BaseMessage) or not isinstance(message.content, list):
|
|
65
138
|
continue
|
|
66
139
|
for block in message.content:
|
|
67
|
-
|
|
68
|
-
if
|
|
140
|
+
inline = _inline_payload(block)
|
|
141
|
+
if inline is None or inline[0] in pending:
|
|
69
142
|
continue
|
|
143
|
+
payload = inline[0]
|
|
70
144
|
try:
|
|
71
145
|
raw = base64.b64decode(payload, validate=True)
|
|
72
146
|
except (ValueError, binascii.Error):
|
|
@@ -79,9 +153,11 @@ def _stub_messages(messages: Sequence[Any], digests: dict[str, str]) -> list[Any
|
|
|
79
153
|
"""Replace payloads found in `digests` with blob references."""
|
|
80
154
|
|
|
81
155
|
def stub(block: Any) -> Any: # noqa: ANN401
|
|
82
|
-
|
|
156
|
+
inline = _inline_payload(block)
|
|
157
|
+
if inline is None or inline[0] not in digests:
|
|
83
158
|
return block
|
|
84
|
-
|
|
159
|
+
payload, data_url_mime = inline
|
|
160
|
+
return _stub_block(block, digests[payload], data_url_mime)
|
|
85
161
|
|
|
86
162
|
result = []
|
|
87
163
|
for message in messages:
|
|
@@ -113,7 +189,7 @@ def _offload_messages(messages: Sequence[Any], backend: BackendProtocol, prefix:
|
|
|
113
189
|
try:
|
|
114
190
|
responses = backend.upload_files([(_blob_path(prefix, digest), raw) for digest, raw in pending.values()])
|
|
115
191
|
except Exception: # noqa: BLE001 -- offload is best-effort; the payload stays inline
|
|
116
|
-
logger.warning("Failed to offload binary
|
|
192
|
+
logger.warning("Failed to offload binary content; keeping it inline", exc_info=True)
|
|
117
193
|
return list(messages)
|
|
118
194
|
return _stub_messages(messages, _stored_digests(pending, [r.error for r in responses], cache))
|
|
119
195
|
|
|
@@ -126,7 +202,7 @@ async def _aoffload_messages(messages: Sequence[Any], backend: BackendProtocol,
|
|
|
126
202
|
try:
|
|
127
203
|
responses = await backend.aupload_files([(_blob_path(prefix, digest), raw) for digest, raw in pending.values()])
|
|
128
204
|
except Exception: # noqa: BLE001 -- offload is best-effort; the payload stays inline
|
|
129
|
-
logger.warning("Failed to offload binary
|
|
205
|
+
logger.warning("Failed to offload binary content; keeping it inline", exc_info=True)
|
|
130
206
|
return list(messages)
|
|
131
207
|
return _stub_messages(messages, _stored_digests(pending, [r.error for r in responses], cache))
|
|
132
208
|
|
|
@@ -151,10 +227,10 @@ async def _aoffload_tool_result(result: ToolMessage | Command, backend: BackendP
|
|
|
151
227
|
|
|
152
228
|
|
|
153
229
|
def _history_candidates(state_messages: Sequence[AnyMessage], pending: Sequence[AnyMessage]) -> list[HumanMessage | ToolMessage]:
|
|
154
|
-
"""Collect human and
|
|
230
|
+
"""Collect human and tool messages, including imported history."""
|
|
155
231
|
queued = {m.id: m for m in pending if isinstance(m, BaseMessage) and m.id is not None}
|
|
156
232
|
candidates = (queued.get(m.id, m) for m in state_messages if isinstance(m, BaseMessage) and m.id is not None)
|
|
157
|
-
return [m for m in candidates if isinstance(m, HumanMessage
|
|
233
|
+
return [m for m in candidates if isinstance(m, HumanMessage | ToolMessage)]
|
|
158
234
|
|
|
159
235
|
|
|
160
236
|
def _merge_replacements(pending: Sequence[Any], offloaded: Sequence[Any], candidates: Sequence[Any]) -> list[Any]:
|
|
@@ -166,7 +242,7 @@ def _merge_replacements(pending: Sequence[Any], offloaded: Sequence[Any], candid
|
|
|
166
242
|
def _offload_history_messages(
|
|
167
243
|
state_messages: Sequence[Any], pending: Sequence[Any], backend: BackendProtocol, prefix: str, cache: dict[str, str]
|
|
168
244
|
) -> list[Any]:
|
|
169
|
-
"""Return `pending` plus stubbed replacements for human
|
|
245
|
+
"""Return `pending` plus stubbed replacements for human and tool media in state."""
|
|
170
246
|
candidates = _history_candidates(state_messages, pending)
|
|
171
247
|
return _merge_replacements(pending, _offload_messages(candidates, backend, prefix, cache), candidates)
|
|
172
248
|
|
|
@@ -185,7 +261,8 @@ def _referenced_digests(messages: Sequence[BaseMessage]) -> list[str]:
|
|
|
185
261
|
if not isinstance(message.content, list):
|
|
186
262
|
continue
|
|
187
263
|
for block in message.content:
|
|
188
|
-
|
|
264
|
+
holder = _ref_holder(block)
|
|
265
|
+
ref = holder.get(_BLOB_REF_KEY) if holder is not None else None
|
|
189
266
|
if isinstance(ref, str) and _DIGEST_RE.fullmatch(ref):
|
|
190
267
|
digests[ref] = None
|
|
191
268
|
return list(digests)
|
|
@@ -207,18 +284,19 @@ def _accept_downloads(missing: list[str], responses: Sequence[FileDownloadRespon
|
|
|
207
284
|
|
|
208
285
|
|
|
209
286
|
def _message_has_refs(message: BaseMessage) -> bool:
|
|
210
|
-
return isinstance(message.content, list) and any(
|
|
287
|
+
return isinstance(message.content, list) and any(_ref_holder(block) is not None for block in message.content)
|
|
211
288
|
|
|
212
289
|
|
|
213
290
|
def _restore_payloads(messages: Sequence[AnyMessage], payloads: dict[str, str]) -> list[AnyMessage]:
|
|
214
291
|
def hydrate(block: Any) -> Any: # noqa: ANN401
|
|
215
|
-
|
|
292
|
+
holder = _ref_holder(block)
|
|
293
|
+
if holder is None:
|
|
216
294
|
return block
|
|
217
|
-
ref =
|
|
295
|
+
ref = holder[_BLOB_REF_KEY]
|
|
218
296
|
payload = payloads.get(ref) if isinstance(ref, str) else None
|
|
219
297
|
if payload is None:
|
|
220
298
|
return {"type": "text", "text": _MISSING_BLOB_TEXT}
|
|
221
|
-
return
|
|
299
|
+
return _without_ref(block) | {"base64": payload}
|
|
222
300
|
|
|
223
301
|
result = []
|
|
224
302
|
for message in messages:
|
|
@@ -255,7 +333,7 @@ def _hydrate_messages(messages: Sequence[AnyMessage], backend: BackendProtocol,
|
|
|
255
333
|
try:
|
|
256
334
|
responses = backend.download_files([_blob_path(prefix, digest) for digest in missing])
|
|
257
335
|
except Exception: # noqa: BLE001 -- unavailable blobs degrade to a text notice
|
|
258
|
-
logger.warning("Failed to load offloaded
|
|
336
|
+
logger.warning("Failed to load offloaded binary content", exc_info=True)
|
|
259
337
|
responses = []
|
|
260
338
|
_accept_downloads(missing, responses, payloads, cache)
|
|
261
339
|
return _restore_payloads(messages, payloads)
|
|
@@ -270,7 +348,7 @@ async def _ahydrate_messages(messages: Sequence[AnyMessage], backend: BackendPro
|
|
|
270
348
|
try:
|
|
271
349
|
responses = await backend.adownload_files([_blob_path(prefix, digest) for digest in missing])
|
|
272
350
|
except Exception: # noqa: BLE001 -- unavailable blobs degrade to a text notice
|
|
273
|
-
logger.warning("Failed to load offloaded
|
|
351
|
+
logger.warning("Failed to load offloaded binary content", exc_info=True)
|
|
274
352
|
responses = []
|
|
275
353
|
_accept_downloads(missing, responses, payloads, cache)
|
|
276
354
|
return _restore_payloads(messages, payloads)
|
|
@@ -669,6 +669,44 @@ def _final_content(values: Mapping[str, Any]) -> list[ContentBlock]:
|
|
|
669
669
|
return last_message.content_blocks
|
|
670
670
|
|
|
671
671
|
|
|
672
|
+
_LAST_MESSAGE = "last_message"
|
|
673
|
+
"""The `extract` alias for a thread's last message."""
|
|
674
|
+
|
|
675
|
+
_OBSERVED_THREAD = {"select": ["thread_id", "status", "interrupts"], "extract": {_LAST_MESSAGE: "values.messages[-1]"}}
|
|
676
|
+
"""Read only what a task check needs, so the thread's state doesn't leave the server."""
|
|
677
|
+
|
|
678
|
+
_THREAD_STATUS = {"select": ["thread_id", "status"]}
|
|
679
|
+
"""Read only a thread's status."""
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def _slim_thread(found: Sequence[Thread], query: Mapping[str, Any]) -> Thread | None:
|
|
683
|
+
"""The thread a `threads.search` by ID found; with `extract`, its last message is its only value.
|
|
684
|
+
|
|
685
|
+
`None` sends the caller back to `threads.get`: the search found nothing (so `get`
|
|
686
|
+
raises the real error), or an Agent Server older than `extract` ignored it.
|
|
687
|
+
"""
|
|
688
|
+
thread = next(iter(found), None)
|
|
689
|
+
extracted = thread.get("extracted") if thread else None
|
|
690
|
+
if thread is None or ("extract" in query and not isinstance(extracted, Mapping)):
|
|
691
|
+
return None
|
|
692
|
+
if "extract" in query:
|
|
693
|
+
last = cast("Mapping[str, Any]", extracted).get(_LAST_MESSAGE)
|
|
694
|
+
thread = cast("Thread", {**thread, "values": {"messages": [] if last is None else [last]}})
|
|
695
|
+
return thread
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
def _read_thread(client: SyncLangGraphClient, thread_id: str, query: Mapping[str, Any]) -> Thread:
|
|
699
|
+
"""Read a thread's `query` fields with a search by ID, which skips its full state; `threads.get` as the fallback."""
|
|
700
|
+
found = client.threads.search(ids=[thread_id], limit=1, **query)
|
|
701
|
+
return _slim_thread(found, query) or client.threads.get(thread_id=thread_id)
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
async def _aread_thread(client: LangGraphClient, thread_id: str, query: Mapping[str, Any]) -> Thread:
|
|
705
|
+
"""Async version of `_read_thread`."""
|
|
706
|
+
found = await client.threads.search(ids=[thread_id], limit=1, **query)
|
|
707
|
+
return _slim_thread(found, query) or await client.threads.get(thread_id=thread_id)
|
|
708
|
+
|
|
709
|
+
|
|
672
710
|
_DELIVERABLE_THREAD_STATUSES = frozenset({"idle", "error"})
|
|
673
711
|
"""Parent thread statuses a notification run can start on: neither running nor waiting for a human."""
|
|
674
712
|
|
|
@@ -681,7 +719,7 @@ async def _awake_parent(parent_thread_id: str, assistant_id: str, event: _TaskUp
|
|
|
681
719
|
"""
|
|
682
720
|
client = get_client()
|
|
683
721
|
try:
|
|
684
|
-
if (await client
|
|
722
|
+
if (await _aread_thread(client, parent_thread_id, _THREAD_STATUS)).get("status") not in _DELIVERABLE_THREAD_STATUSES:
|
|
685
723
|
return
|
|
686
724
|
await client.runs.create(
|
|
687
725
|
thread_id=parent_thread_id,
|
|
@@ -941,7 +979,7 @@ def _observe(client: SyncLangGraphClient, task: AsyncTask) -> tuple[Run, Thread
|
|
|
941
979
|
run = next(iter(client.runs.list(thread_id=task["thread_id"], limit=1)), run)
|
|
942
980
|
if run["status"] != "success":
|
|
943
981
|
return run, None
|
|
944
|
-
thread = client
|
|
982
|
+
thread = _read_thread(client, task["thread_id"], _OBSERVED_THREAD)
|
|
945
983
|
if _needs_latest_run(run, thread):
|
|
946
984
|
run = next(iter(client.runs.list(thread_id=task["thread_id"], limit=1)), run)
|
|
947
985
|
return run, thread
|
|
@@ -954,7 +992,7 @@ async def _aobserve(client: LangGraphClient, task: AsyncTask) -> tuple[Run, Thre
|
|
|
954
992
|
run = next(iter(await client.runs.list(thread_id=task["thread_id"], limit=1)), run)
|
|
955
993
|
if run["status"] != "success":
|
|
956
994
|
return run, None
|
|
957
|
-
thread = await client
|
|
995
|
+
thread = await _aread_thread(client, task["thread_id"], _OBSERVED_THREAD)
|
|
958
996
|
if _needs_latest_run(run, thread):
|
|
959
997
|
run = next(iter(await client.runs.list(thread_id=task["thread_id"], limit=1)), run)
|
|
960
998
|
return run, thread
|
|
@@ -277,15 +277,22 @@ def _replace_rejected_file_content(messages: list[AnyMessage]) -> list[AnyMessag
|
|
|
277
277
|
"""Replace only multimodal reads since the latest model response."""
|
|
278
278
|
last_response = next((index for index in range(len(messages) - 1, -1, -1) if isinstance(messages[index], AIMessage)), -1)
|
|
279
279
|
return [
|
|
280
|
-
message
|
|
280
|
+
_without_media(message)
|
|
281
281
|
if index > last_response
|
|
282
|
-
and (_is_read_file_media_result(message) or
|
|
282
|
+
and (_is_read_file_media_result(message) or isinstance(message, ToolMessage))
|
|
283
283
|
and any(block["type"] in _MULTIMODAL_BLOCK_TYPES for block in message.content_blocks)
|
|
284
284
|
else message
|
|
285
285
|
for index, message in enumerate(messages)
|
|
286
286
|
]
|
|
287
287
|
|
|
288
288
|
|
|
289
|
+
def _without_media(message: AnyMessage) -> AnyMessage:
|
|
290
|
+
"""Replace media with a notice, keeping a tool result's other blocks."""
|
|
291
|
+
notice = "Unsupported content. The file may be invalid, too large, or of an unsupported mime-type."
|
|
292
|
+
kept = [block for block in message.content_blocks if block["type"] not in _MULTIMODAL_BLOCK_TYPES] if isinstance(message, ToolMessage) else []
|
|
293
|
+
return message.model_copy(update={"content": [*kept, {"type": "text", "text": notice}] if kept else notice})
|
|
294
|
+
|
|
295
|
+
|
|
289
296
|
def _handle_video_read(
|
|
290
297
|
content: str,
|
|
291
298
|
validated_path: str,
|
|
@@ -407,7 +414,20 @@ class FilesystemPermission:
|
|
|
407
414
|
"""
|
|
408
415
|
|
|
409
416
|
def __post_init__(self) -> None:
|
|
410
|
-
"""Validate permission path patterns."""
|
|
417
|
+
"""Validate permission modes, operations, and path patterns."""
|
|
418
|
+
if self.mode not in ("allow", "deny", "interrupt"):
|
|
419
|
+
msg = f"Permission mode must be 'allow', 'deny', or 'interrupt': {self.mode!r}"
|
|
420
|
+
raise ValueError(msg)
|
|
421
|
+
if isinstance(self.operations, str):
|
|
422
|
+
msg = "Permission operations must be a list, not a string; use ['read'] or ['write']"
|
|
423
|
+
raise TypeError(msg)
|
|
424
|
+
if not self.operations:
|
|
425
|
+
msg = "Permission operations must not be empty"
|
|
426
|
+
raise ValueError(msg)
|
|
427
|
+
for operation in self.operations:
|
|
428
|
+
if operation not in ("read", "write"):
|
|
429
|
+
msg = f"Permission operation must be 'read' or 'write': {operation!r}"
|
|
430
|
+
raise ValueError(msg)
|
|
411
431
|
for path in self.paths:
|
|
412
432
|
if not path.startswith("/"):
|
|
413
433
|
msg = f"Permission path must start with '/': {path!r}"
|
|
@@ -1166,7 +1186,7 @@ def _discard_task_result(task: asyncio.Future[Any]) -> None:
|
|
|
1166
1186
|
|
|
1167
1187
|
|
|
1168
1188
|
DEFAULT_READ_OFFSET = 0
|
|
1169
|
-
DEFAULT_READ_LIMIT =
|
|
1189
|
+
DEFAULT_READ_LIMIT = 1000
|
|
1170
1190
|
# Template for truncation message in read_file
|
|
1171
1191
|
# {file_path} will be filled in at runtime
|
|
1172
1192
|
READ_FILE_TRUNCATION_MSG = (
|
|
@@ -1600,15 +1620,15 @@ _IMAGE_PDF_PAGINATION_BULLET = "- For images and PDFs, pagination via `offset`/`
|
|
|
1600
1620
|
"""Multimodal bullet shared by both `read_file` descriptions (images/PDFs are not paginated)."""
|
|
1601
1621
|
|
|
1602
1622
|
READ_FILE_TOOL_DESCRIPTION = _READ_FILE_TOOL_DESCRIPTION_TEMPLATE.format(
|
|
1603
|
-
first_line="By default, it reads up to
|
|
1623
|
+
first_line=f"By default, it reads up to {DEFAULT_READ_LIMIT} lines starting from the beginning of the file",
|
|
1604
1624
|
multimodal_bullets=_IMAGE_PDF_PAGINATION_BULLET,
|
|
1605
1625
|
)
|
|
1606
1626
|
|
|
1607
1627
|
READ_FILE_VIDEO_TOOL_DESCRIPTION = _READ_FILE_TOOL_DESCRIPTION_TEMPLATE.format(
|
|
1608
|
-
first_line="For text files, by default it reads up to
|
|
1628
|
+
first_line=f"For text files, by default it reads up to {DEFAULT_READ_LIMIT} lines starting from the beginning of the file",
|
|
1609
1629
|
multimodal_bullets=(
|
|
1610
1630
|
f"{_IMAGE_PDF_PAGINATION_BULLET}\n"
|
|
1611
|
-
"- For videos, `offset`/`limit` are interpreted as seconds (default window
|
|
1631
|
+
f"- For videos, `offset`/`limit` are interpreted as seconds (default window {DEFAULT_READ_LIMIT} s; sampled at a fixed rate). Use smaller windows when you need more temporal detail."
|
|
1612
1632
|
),
|
|
1613
1633
|
)
|
|
1614
1634
|
|
|
@@ -2025,17 +2045,19 @@ class FilesystemMiddleware(AgentMiddleware[FilesystemState, ContextT, ResponseT]
|
|
|
2025
2045
|
in any list. Backend capability checks for `execute` and
|
|
2026
2046
|
`delete` still apply; listing them when the backend does not
|
|
2027
2047
|
support them is a no-op.
|
|
2028
|
-
offload_binary_content: Keep
|
|
2029
|
-
|
|
2048
|
+
offload_binary_content: Keep inline media in human messages and
|
|
2049
|
+
tool results out of message history.
|
|
2030
2050
|
|
|
2031
2051
|
Payloads are written to `blobs/` under the artifacts root and
|
|
2032
2052
|
state keeps a content-addressed reference; model requests are
|
|
2033
|
-
rehydrated from the backend.
|
|
2034
|
-
|
|
2035
|
-
conversations,
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2053
|
+
rehydrated from the backend. Tool results are offloaded as they
|
|
2054
|
+
are returned; inline media in human and tool messages anywhere in
|
|
2055
|
+
the history, including imported conversations, is replaced at the
|
|
2056
|
+
next model call. Media is inline when a block carries `base64` or
|
|
2057
|
+
a base64 `data:` URL. The original input write stays in
|
|
2058
|
+
checkpoint history. Useful with sandbox backends; route `blobs/`
|
|
2059
|
+
to another backend with `CompositeBackend` to keep blobs
|
|
2060
|
+
elsewhere. Has no effect when `blobs/` routes to a `StateBackend`.
|
|
2039
2061
|
permissions: Filesystem rules enforced by this middleware's tools.
|
|
2040
2062
|
`create_deep_agent` supplies its rules when this list is empty;
|
|
2041
2063
|
conflicting non-empty rule lists raise `ValueError`.
|
|
@@ -3974,7 +3996,7 @@ class FilesystemMiddleware(AgentMiddleware[FilesystemState, ContextT, ResponseT]
|
|
|
3974
3996
|
return error
|
|
3975
3997
|
with _tool_blob_store(self.backend if self._offload_binary_content else None, self._blobs_prefix):
|
|
3976
3998
|
tool_result = handler(request)
|
|
3977
|
-
if self._offload_binary_content
|
|
3999
|
+
if self._offload_binary_content:
|
|
3978
4000
|
tool_result = _offload_tool_result(tool_result, self.backend, self._blobs_prefix, {})
|
|
3979
4001
|
|
|
3980
4002
|
if self._tool_token_limit_before_evict is None or request.tool_call["name"] in TOOLS_EXCLUDED_FROM_EVICTION:
|
|
@@ -4004,7 +4026,7 @@ class FilesystemMiddleware(AgentMiddleware[FilesystemState, ContextT, ResponseT]
|
|
|
4004
4026
|
return error
|
|
4005
4027
|
with _tool_blob_store(self.backend if self._offload_binary_content else None, self._blobs_prefix):
|
|
4006
4028
|
tool_result = await handler(request)
|
|
4007
|
-
if self._offload_binary_content
|
|
4029
|
+
if self._offload_binary_content:
|
|
4008
4030
|
tool_result = await _aoffload_tool_result(tool_result, self.backend, self._blobs_prefix, {})
|
|
4009
4031
|
|
|
4010
4032
|
if self._tool_token_limit_before_evict is None or request.tool_call["name"] in TOOLS_EXCLUDED_FROM_EVICTION:
|
|
@@ -136,7 +136,7 @@ from langchain.agents.middleware.types import (
|
|
|
136
136
|
)
|
|
137
137
|
from langgraph.types import Command, Overwrite
|
|
138
138
|
|
|
139
|
-
from deepagents.backends.protocol import FILE_NOT_FOUND, FileDownloadResponse, LsResult
|
|
139
|
+
from deepagents.backends.protocol import FILE_NOT_FOUND, FileDownloadResponse, FileInfo, LsResult
|
|
140
140
|
from deepagents.backends.utils import to_posix_path
|
|
141
141
|
from deepagents.middleware._skill_tools import (
|
|
142
142
|
_INCLUDE_TOOLS_KEY,
|
|
@@ -681,6 +681,13 @@ def _format_skills_source_error(source_path: str, error: str) -> str:
|
|
|
681
681
|
return f"Cannot load skills from '{source_path}': {error}"
|
|
682
682
|
|
|
683
683
|
|
|
684
|
+
def _skill_dirs(items: Sequence[FileInfo], source_path: str) -> list[str]:
|
|
685
|
+
for item in items:
|
|
686
|
+
if not item.get("is_dir") and PurePosixPath(to_posix_path(item["path"])).name == "SKILL.md":
|
|
687
|
+
return [source_path]
|
|
688
|
+
return [item["path"] for item in items if item.get("is_dir")]
|
|
689
|
+
|
|
690
|
+
|
|
684
691
|
def _list_skills_with_errors(backend: BackendProtocol, source_path: str) -> tuple[list[SkillMetadata], str | None]:
|
|
685
692
|
"""List all skills from a backend source.
|
|
686
693
|
|
|
@@ -713,13 +720,7 @@ def _list_skills_with_errors(backend: BackendProtocol, source_path: str) -> tupl
|
|
|
713
720
|
|
|
714
721
|
items = ls_result.entries if isinstance(ls_result, LsResult) else ls_result
|
|
715
722
|
|
|
716
|
-
|
|
717
|
-
skill_dirs = []
|
|
718
|
-
for item in items or []:
|
|
719
|
-
if not item.get("is_dir"):
|
|
720
|
-
continue
|
|
721
|
-
skill_dirs.append(item["path"])
|
|
722
|
-
|
|
723
|
+
skill_dirs = _skill_dirs(items or [], source_path)
|
|
723
724
|
if not skill_dirs:
|
|
724
725
|
return [], source_error
|
|
725
726
|
|
|
@@ -779,13 +780,7 @@ async def _alist_skills_with_errors(backend: BackendProtocol, source_path: str)
|
|
|
779
780
|
|
|
780
781
|
items = ls_result.entries if isinstance(ls_result, LsResult) else ls_result
|
|
781
782
|
|
|
782
|
-
|
|
783
|
-
skill_dirs = []
|
|
784
|
-
for item in items or []:
|
|
785
|
-
if not item.get("is_dir"):
|
|
786
|
-
continue
|
|
787
|
-
skill_dirs.append(item["path"])
|
|
788
|
-
|
|
783
|
+
skill_dirs = _skill_dirs(items or [], source_path)
|
|
789
784
|
if not skill_dirs:
|
|
790
785
|
return [], source_error
|
|
791
786
|
|
|
@@ -883,7 +878,7 @@ Skills follow a **progressive disclosure** pattern - you see their name and desc
|
|
|
883
878
|
|
|
884
879
|
1. **Recognize when a skill applies**: Check if the user's task matches a skill's description
|
|
885
880
|
2. **Read the skill's full instructions**: Use `read_file` on the path shown in the skill list above.
|
|
886
|
-
|
|
881
|
+
Read the entire file, continuing with `offset`/`limit` if the result is truncated.
|
|
887
882
|
3. **Follow the skill's instructions**: SKILL.md contains step-by-step workflows, best practices, and examples
|
|
888
883
|
4. **Access supporting files**: Skills may include helper scripts, configs, or reference docs - use absolute paths
|
|
889
884
|
|
|
@@ -137,6 +137,9 @@ if TYPE_CHECKING:
|
|
|
137
137
|
|
|
138
138
|
logger = logging.getLogger(__name__)
|
|
139
139
|
|
|
140
|
+
_OUTPUT_RESERVE_CAP_DIVISOR = 4
|
|
141
|
+
"""Cap on the output reservation, as a fraction of the input limit, when output fills the whole budget."""
|
|
142
|
+
|
|
140
143
|
|
|
141
144
|
class CompactConversationSchema(BaseModel):
|
|
142
145
|
"""Input schema for the `compact_conversation` tool."""
|
|
@@ -1537,7 +1540,13 @@ A condensed summary follows:
|
|
|
1537
1540
|
raise ContextOverflowError(msg) from error
|
|
1538
1541
|
|
|
1539
1542
|
def _input_budget(self, request: ModelRequest) -> int | None:
|
|
1540
|
-
"""Reserve configured output and 5% headroom from the advertised input limit.
|
|
1543
|
+
"""Reserve configured output and 5% headroom from the advertised input limit.
|
|
1544
|
+
|
|
1545
|
+
When the configured output is at least the whole budget, such as a
|
|
1546
|
+
provider default that sets `max_tokens` to a model's full window, the
|
|
1547
|
+
reservation is capped at a quarter of the limit instead of leaving no
|
|
1548
|
+
room for input at all.
|
|
1549
|
+
"""
|
|
1541
1550
|
profile = request.model.profile
|
|
1542
1551
|
limit = profile.get("max_input_tokens") if isinstance(profile, dict) else None
|
|
1543
1552
|
if not isinstance(limit, int) or isinstance(limit, bool):
|
|
@@ -1547,7 +1556,9 @@ A condensed summary follows:
|
|
|
1547
1556
|
value = request.model_settings.get(key, getattr(request.model, key, None))
|
|
1548
1557
|
if isinstance(value, int) and not isinstance(value, bool):
|
|
1549
1558
|
output = max(output, value)
|
|
1550
|
-
|
|
1559
|
+
headroom = int(limit * 0.95)
|
|
1560
|
+
reserved = output if output < headroom else min(output, limit // _OUTPUT_RESERVE_CAP_DIVISOR)
|
|
1561
|
+
return max(0, headroom - reserved)
|
|
1551
1562
|
|
|
1552
1563
|
def _over_budget(self, request: ModelRequest, total_tokens: int | None = None) -> bool:
|
|
1553
1564
|
budget = self._input_budget(request)
|
|
@@ -30,8 +30,10 @@ from deepagents.profiles.harness import (
|
|
|
30
30
|
_anthropic_haiku_4_5,
|
|
31
31
|
_anthropic_opus_4_7,
|
|
32
32
|
_anthropic_sonnet_4_6,
|
|
33
|
+
_fireworks_kimi_k3p1_pro,
|
|
33
34
|
_nvidia_nemotron_3_ultra,
|
|
34
35
|
_openai_codex,
|
|
36
|
+
_openai_gpt_6_1_sol,
|
|
35
37
|
)
|
|
36
38
|
from deepagents.profiles.harness.harness_profiles import _HARNESS_PROFILES
|
|
37
39
|
from deepagents.profiles.provider import _nvidia, _openai, _openrouter
|
|
@@ -154,6 +156,8 @@ def _ensure_builtin_profiles_loaded() -> None:
|
|
|
154
156
|
_anthropic_haiku_4_5.register()
|
|
155
157
|
_nvidia_nemotron_3_ultra.register()
|
|
156
158
|
_openai_codex.register()
|
|
159
|
+
_openai_gpt_6_1_sol.register()
|
|
160
|
+
_fireworks_kimi_k3p1_pro.register()
|
|
157
161
|
plugins = _discover_profile_plugins()
|
|
158
162
|
_invoke_profile_plugins(_PROVIDER_PROFILE_GROUP, plugins[_PROVIDER_PROFILE_GROUP])
|
|
159
163
|
_invoke_profile_plugins(_HARNESS_PROFILE_GROUP, plugins[_HARNESS_PROFILE_GROUP])
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Built-in Kimi K3.1 Pro (Fireworks) harness profile.
|
|
2
|
+
|
|
3
|
+
Applies the same selective delegation guidance as the GPT-6.1 Sol profile:
|
|
4
|
+
the `task` tool and general-purpose subagent descriptions keep routine work
|
|
5
|
+
with the parent and reserve subagents for substantial, independent work.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from deepagents.profiles.harness._openai_gpt_6_1_sol import (
|
|
9
|
+
_GENERAL_PURPOSE_DESCRIPTION,
|
|
10
|
+
_TASK_DESCRIPTION,
|
|
11
|
+
)
|
|
12
|
+
from deepagents.profiles.harness.harness_profiles import (
|
|
13
|
+
GeneralPurposeSubagentProfile,
|
|
14
|
+
HarnessProfile,
|
|
15
|
+
_register_harness_profile_impl,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def register() -> None:
|
|
20
|
+
"""Register the built-in Kimi K3.1 Pro harness profile."""
|
|
21
|
+
_register_harness_profile_impl(
|
|
22
|
+
"fireworks:accounts/fireworks/models/kimi-k3p1-pro",
|
|
23
|
+
HarnessProfile(
|
|
24
|
+
tool_description_overrides={"task": _TASK_DESCRIPTION},
|
|
25
|
+
general_purpose_subagent=GeneralPurposeSubagentProfile(description=_GENERAL_PURPOSE_DESCRIPTION),
|
|
26
|
+
),
|
|
27
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Built-in GPT-6.1 Sol harness profile.
|
|
2
|
+
|
|
3
|
+
Replaces the `task` tool and general-purpose subagent descriptions for
|
|
4
|
+
`openai:gpt-6.1-sol` with selective delegation guidance: keep routine work
|
|
5
|
+
with the parent and reserve subagents for substantial, independent work.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# ruff: noqa: E501
|
|
9
|
+
# Model-facing prompt lines are kept unwrapped.
|
|
10
|
+
|
|
11
|
+
from deepagents.profiles.harness.harness_profiles import (
|
|
12
|
+
GeneralPurposeSubagentProfile,
|
|
13
|
+
HarnessProfile,
|
|
14
|
+
_register_harness_profile_impl,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
_TASK_DESCRIPTION = """Launch an ephemeral subagent to handle a well-scoped task.
|
|
18
|
+
|
|
19
|
+
Available agent types and the tools they have access to:
|
|
20
|
+
{available_agents}
|
|
21
|
+
|
|
22
|
+
Specify subagent_type to select the agent. Usage notes:
|
|
23
|
+
- Select an agent according to its description and the user's explicit requirements.
|
|
24
|
+
- Launch multiple agents concurrently when their tasks are independent and their write scopes do not conflict, using a single message with multiple tool calls.
|
|
25
|
+
- Each invocation is stateless by default: the agent sees only the prompt you give it and returns a single final report. Put sufficient context in the prompt — unless an agent type below says it inherits your conversation instead. State a bounded deliverable, relevant constraints, and the expected result.
|
|
26
|
+
- The agent's report is not shown to the user; relay a summary yourself.
|
|
27
|
+
- Tell the agent whether to create content, analyze, or only research, since it can't necessarily see the user's intent unless it inherits your conversation, as noted per agent type below.
|
|
28
|
+
- If an agent's description says to use it proactively, do so without waiting to be asked."""
|
|
29
|
+
"""`task` tool description template; `{available_agents}` lists the subagents."""
|
|
30
|
+
|
|
31
|
+
_GENERAL_PURPOSE_DESCRIPTION = (
|
|
32
|
+
"General-purpose agent for substantial, independent work with its own deliverable, "
|
|
33
|
+
"such as a separate part of the solution that can proceed in parallel with yours. "
|
|
34
|
+
"Do not delegate reviews, audits, re-derivations, or verification of work you are doing or have done; "
|
|
35
|
+
"check it yourself with direct tools. "
|
|
36
|
+
"Do not hand off a phase (research, implementation, testing) of a task you own. "
|
|
37
|
+
"Prefer direct tools for searches, reading code, small edits, and tightly coupled next steps. "
|
|
38
|
+
"Complexity or uncertainty is not sufficient reason to delegate. "
|
|
39
|
+
"This agent has the same capabilities as the main agent."
|
|
40
|
+
)
|
|
41
|
+
"""General-purpose subagent description shown in the `task` tool listing."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def register() -> None:
|
|
45
|
+
"""Register the built-in GPT-6.1 Sol harness profile."""
|
|
46
|
+
_register_harness_profile_impl(
|
|
47
|
+
"openai:gpt-6.1-sol",
|
|
48
|
+
HarnessProfile(
|
|
49
|
+
tool_description_overrides={"task": _TASK_DESCRIPTION},
|
|
50
|
+
general_purpose_subagent=GeneralPurposeSubagentProfile(description=_GENERAL_PURPOSE_DESCRIPTION),
|
|
51
|
+
),
|
|
52
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepagents
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.45
|
|
4
4
|
Summary: Production-ready, extensible agent harness with a built-in filesystem and context management, sub-agent delegation, skills, and long-term memory.
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Homepage, https://docs.langchain.com/oss/python/deepagents/overview
|
|
@@ -25,11 +25,11 @@ Requires-Python: <4.0,>=3.11
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: langchain<2.0.0,>=1.5.2
|
|
28
|
-
Requires-Dist: langchain-core<2.0.0,>=1.
|
|
29
|
-
Requires-Dist: langchain-anthropic<2.0.0,>=1.
|
|
28
|
+
Requires-Dist: langchain-core<2.0.0,>=1.9.0
|
|
29
|
+
Requires-Dist: langchain-anthropic<2.0.0,>=1.8.0
|
|
30
30
|
Requires-Dist: langchain-google-genai<5.0.0,>=4.4.3
|
|
31
|
-
Requires-Dist: langgraph<2.0.0,>=1.2.
|
|
32
|
-
Requires-Dist: langsmith>=0.16.
|
|
31
|
+
Requires-Dist: langgraph<2.0.0,>=1.2.25
|
|
32
|
+
Requires-Dist: langsmith>=0.16.7
|
|
33
33
|
Requires-Dist: packaging>=23.2
|
|
34
34
|
Requires-Dist: wcmatch>=11.0
|
|
35
35
|
Provides-Extra: aws
|
|
@@ -58,8 +58,10 @@ deepagents/profiles/harness/__init__.py
|
|
|
58
58
|
deepagents/profiles/harness/_anthropic_haiku_4_5.py
|
|
59
59
|
deepagents/profiles/harness/_anthropic_opus_4_7.py
|
|
60
60
|
deepagents/profiles/harness/_anthropic_sonnet_4_6.py
|
|
61
|
+
deepagents/profiles/harness/_fireworks_kimi_k3p1_pro.py
|
|
61
62
|
deepagents/profiles/harness/_nvidia_nemotron_3_ultra.py
|
|
62
63
|
deepagents/profiles/harness/_openai_codex.py
|
|
64
|
+
deepagents/profiles/harness/_openai_gpt_6_1_sol.py
|
|
63
65
|
deepagents/profiles/harness/harness_profiles.py
|
|
64
66
|
deepagents/profiles/provider/__init__.py
|
|
65
67
|
deepagents/profiles/provider/_nvidia.py
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
langchain<2.0.0,>=1.5.2
|
|
2
|
-
langchain-core<2.0.0,>=1.
|
|
3
|
-
langchain-anthropic<2.0.0,>=1.
|
|
2
|
+
langchain-core<2.0.0,>=1.9.0
|
|
3
|
+
langchain-anthropic<2.0.0,>=1.8.0
|
|
4
4
|
langchain-google-genai<5.0.0,>=4.4.3
|
|
5
|
-
langgraph<2.0.0,>=1.2.
|
|
6
|
-
langsmith>=0.16.
|
|
5
|
+
langgraph<2.0.0,>=1.2.25
|
|
6
|
+
langsmith>=0.16.7
|
|
7
7
|
packaging>=23.2
|
|
8
8
|
wcmatch>=11.0
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "deepagents"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.45"
|
|
4
4
|
|
|
5
5
|
description = "Production-ready, extensible agent harness with a built-in filesystem and context management, sub-agent delegation, skills, and long-term memory."
|
|
6
6
|
readme = "README.md"
|
|
@@ -21,11 +21,11 @@ classifiers = [
|
|
|
21
21
|
]
|
|
22
22
|
dependencies = [
|
|
23
23
|
"langchain>=1.5.2,<2.0.0",
|
|
24
|
-
"langchain-core>=1.
|
|
25
|
-
"langchain-anthropic>=1.
|
|
24
|
+
"langchain-core>=1.9.0,<2.0.0",
|
|
25
|
+
"langchain-anthropic>=1.8.0,<2.0.0",
|
|
26
26
|
"langchain-google-genai>=4.4.3,<5.0.0",
|
|
27
|
-
"langgraph>=1.2.
|
|
28
|
-
"langsmith>=0.16.
|
|
27
|
+
"langgraph>=1.2.25,<2.0.0",
|
|
28
|
+
"langsmith>=0.16.7",
|
|
29
29
|
"packaging>=23.2",
|
|
30
30
|
"wcmatch>=11.0",
|
|
31
31
|
]
|
|
@@ -59,7 +59,7 @@ test = [
|
|
|
59
59
|
"ty>=0.0.62,<1.0.0",
|
|
60
60
|
"pytest-asyncio>=1.4.0",
|
|
61
61
|
"langchain-tests>=1.2.0",
|
|
62
|
-
"langchain-openai>=1.8.
|
|
62
|
+
"langchain-openai>=1.8.6,<2.0.0",
|
|
63
63
|
# The `aws` extra, so payload tests can drive real langchain-aws chat models.
|
|
64
64
|
"langchain-aws>=1.10.0,<2.0.0",
|
|
65
65
|
"twine",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_anthropic_sonnet_4_6.py
RENAMED
|
File without changes
|
{deepagents-0.7.43 → deepagents-0.7.45}/deepagents/profiles/harness/_nvidia_nemotron_3_ultra.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|