managed-deepagents 0.10.4.dev2__py3-none-win_amd64.whl → 0.10.4.dev4__py3-none-win_amd64.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.
- managed_deepagents/_binaries/mda.exe +0 -0
- managed_deepagents/_credential_gate.py +48 -7
- managed_deepagents/_memory/assistant_memory.py +44 -0
- managed_deepagents/_memory/layers.py +22 -7
- managed_deepagents/_memory/mounts.py +9 -1
- managed_deepagents/_memory/policy.py +7 -2
- managed_deepagents/_memory_instructions.py +10 -1
- managed_deepagents/_run_input.py +27 -4
- managed_deepagents/_sandbox_proxy.py +13 -1
- managed_deepagents/_telemetry/run.py +1 -1
- managed_deepagents/define_memory.py +19 -13
- managed_deepagents/runtime.py +62 -11
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/METADATA +15 -7
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/RECORD +18 -17
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/WHEEL +0 -0
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/entry_points.txt +0 -0
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/licenses/LICENSE +0 -0
- {managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -270,14 +270,14 @@ def _wrap_tool_call(
|
|
|
270
270
|
request: ToolCallRequest,
|
|
271
271
|
handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]],
|
|
272
272
|
) -> ToolMessage | Command[Any]:
|
|
273
|
-
if request.tool is not None:
|
|
274
|
-
return handler(request)
|
|
275
273
|
try:
|
|
274
|
+
if request.tool is not None:
|
|
275
|
+
return handler(request)
|
|
276
276
|
tools = load_tools(request.runtime)
|
|
277
|
+
return _call_connecting(_with_dynamic_tool(request, tools), handler)
|
|
277
278
|
except CredentialStoreUnavailableError as error:
|
|
278
279
|
_record_credential_unavailable(error, "tool_call")
|
|
279
280
|
return _credential_error_message(request)
|
|
280
|
-
return _call_connecting(_with_dynamic_tool(request, tools), handler)
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
async def _awrap_tool_call(
|
|
@@ -285,14 +285,14 @@ async def _awrap_tool_call(
|
|
|
285
285
|
request: ToolCallRequest,
|
|
286
286
|
handler: Callable[[ToolCallRequest], Awaitable[ToolMessage | Command[Any]]],
|
|
287
287
|
) -> ToolMessage | Command[Any]:
|
|
288
|
-
if request.tool is not None:
|
|
289
|
-
return await handler(request)
|
|
290
288
|
try:
|
|
289
|
+
if request.tool is not None:
|
|
290
|
+
return await handler(request)
|
|
291
291
|
tools = await asyncio.to_thread(load_tools, request.runtime)
|
|
292
|
+
return await _acall_connecting(_with_dynamic_tool(request, tools), handler)
|
|
292
293
|
except CredentialStoreUnavailableError as error:
|
|
293
294
|
_record_credential_unavailable(error, "tool_call")
|
|
294
295
|
return _credential_error_message(request)
|
|
295
|
-
return await _acall_connecting(_with_dynamic_tool(request, tools), handler)
|
|
296
296
|
|
|
297
297
|
|
|
298
298
|
def _record_credential_unavailable(
|
|
@@ -305,9 +305,50 @@ def _record_credential_unavailable(
|
|
|
305
305
|
record_log("WARN", "credential store unavailable", attributes=attributes)
|
|
306
306
|
|
|
307
307
|
|
|
308
|
+
_TOOL_CREDENTIAL_UNAVAILABLE = (
|
|
309
|
+
"Credential verification is temporarily unavailable. "
|
|
310
|
+
"The tool could not complete. Please retry later."
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class _CredentialOutageMiddleware(AgentMiddleware[Any, Any, Any]):
|
|
315
|
+
"""Turn credential-store outages inside tools into tool errors when no gate is installed."""
|
|
316
|
+
|
|
317
|
+
@property
|
|
318
|
+
def name(self) -> str:
|
|
319
|
+
return "CredentialOutageMiddleware"
|
|
320
|
+
|
|
321
|
+
def wrap_tool_call(
|
|
322
|
+
self,
|
|
323
|
+
request: ToolCallRequest,
|
|
324
|
+
handler: Callable[[ToolCallRequest], ToolMessage | Command[Any]],
|
|
325
|
+
) -> ToolMessage | Command[Any]:
|
|
326
|
+
try:
|
|
327
|
+
return handler(request)
|
|
328
|
+
except CredentialStoreUnavailableError as error:
|
|
329
|
+
_record_credential_unavailable(error, "tool_call")
|
|
330
|
+
return _credential_error_message(request)
|
|
331
|
+
|
|
332
|
+
async def awrap_tool_call(
|
|
333
|
+
self,
|
|
334
|
+
request: ToolCallRequest,
|
|
335
|
+
handler: Callable[[ToolCallRequest], Awaitable[ToolMessage | Command[Any]]],
|
|
336
|
+
) -> ToolMessage | Command[Any]:
|
|
337
|
+
try:
|
|
338
|
+
return await handler(request)
|
|
339
|
+
except CredentialStoreUnavailableError as error:
|
|
340
|
+
_record_credential_unavailable(error, "tool_call")
|
|
341
|
+
return _credential_error_message(request)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def create_credential_outage_middleware() -> AgentMiddleware[Any, Any, Any]:
|
|
345
|
+
"""Recover from credential-store outages in tools for configs without a gate."""
|
|
346
|
+
return _CredentialOutageMiddleware()
|
|
347
|
+
|
|
348
|
+
|
|
308
349
|
def _credential_error_message(request: ToolCallRequest) -> ToolMessage:
|
|
309
350
|
return ToolMessage(
|
|
310
|
-
content=
|
|
351
|
+
content=_TOOL_CREDENTIAL_UNAVAILABLE,
|
|
311
352
|
tool_call_id=request.tool_call["id"],
|
|
312
353
|
name=request.tool_call["name"],
|
|
313
354
|
status="error",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Assistant-scoped Context Hub backend for ``/memories/assistant/``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from contextvars import ContextVar
|
|
6
|
+
from hashlib import sha256
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from deepagents.backends import ContextHubBackend, FilesystemBackend
|
|
10
|
+
from deepagents.backends.protocol import BackendProtocol
|
|
11
|
+
|
|
12
|
+
from managed_deepagents._memory.user_memory import UserMemoryBackend
|
|
13
|
+
|
|
14
|
+
APPROVED_ASSISTANT: ContextVar[str | None] = ContextVar("mda_approved_assistant", default=None)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def assistant_memory_repo_handle(deploy_handle: str, assistant_id: str) -> str:
|
|
18
|
+
"""Return an opaque child-repo handle for one deployment and assistant."""
|
|
19
|
+
digest = sha256(f"{deploy_handle}\0{assistant_id}".encode()).hexdigest()[:24]
|
|
20
|
+
return f"{deploy_handle}--a--{digest}"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AssistantMemoryBackend(UserMemoryBackend):
|
|
24
|
+
"""Reuse the run-local backend adapter with a trusted assistant binding."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, *, deploy_handle: str, filesystem_root: str | None) -> None:
|
|
27
|
+
super().__init__(
|
|
28
|
+
deploy_handle=deploy_handle,
|
|
29
|
+
filesystem_root=filesystem_root,
|
|
30
|
+
run_config=None,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def _repo_handle(self) -> str:
|
|
34
|
+
assistant_id = APPROVED_ASSISTANT.get()
|
|
35
|
+
if assistant_id is None:
|
|
36
|
+
raise ValueError("Assistant memory requires a trusted runtime assistant identity")
|
|
37
|
+
return assistant_memory_repo_handle(self._deploy_handle, assistant_id)
|
|
38
|
+
|
|
39
|
+
def _open(self, handle: str) -> BackendProtocol:
|
|
40
|
+
if self._filesystem_root is not None:
|
|
41
|
+
root_dir = str(Path(self._filesystem_root) / "__assistants__" / handle)
|
|
42
|
+
Path(root_dir).mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
43
|
+
return FilesystemBackend(root_dir=root_dir, virtual_mode=True)
|
|
44
|
+
return ContextHubBackend(handle)
|
|
@@ -18,6 +18,7 @@ from typing import Any, Literal, NotRequired, TypeAlias, TypedDict, cast
|
|
|
18
18
|
|
|
19
19
|
__all__ = [
|
|
20
20
|
"AgentMemoryLayer",
|
|
21
|
+
"AssistantMemoryLayer",
|
|
21
22
|
"MemoryLayer",
|
|
22
23
|
"MemoryLayerType",
|
|
23
24
|
"MemoryLayers",
|
|
@@ -36,6 +37,13 @@ class AgentMemoryLayer(TypedDict):
|
|
|
36
37
|
allow: NotRequired[Callable[[Any], bool | Awaitable[bool]]]
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
class AssistantMemoryLayer(TypedDict):
|
|
41
|
+
"""Assistant-scoped memory keyed by the trusted runtime assistant."""
|
|
42
|
+
|
|
43
|
+
type: Literal["assistant"]
|
|
44
|
+
allow: NotRequired[Callable[[Any], bool | Awaitable[bool]]]
|
|
45
|
+
|
|
46
|
+
|
|
39
47
|
class UserMemoryLayerRequired(TypedDict):
|
|
40
48
|
type: Literal["user"]
|
|
41
49
|
|
|
@@ -52,12 +60,12 @@ class UserMemoryLayer(UserMemoryLayerRequired, total=False):
|
|
|
52
60
|
|
|
53
61
|
|
|
54
62
|
#: One mounted layer. The union mirrors ``CredentialOwner``.
|
|
55
|
-
MemoryLayer: TypeAlias = AgentMemoryLayer | UserMemoryLayer
|
|
63
|
+
MemoryLayer: TypeAlias = AgentMemoryLayer | AssistantMemoryLayer | UserMemoryLayer
|
|
56
64
|
MemoryLayers: TypeAlias = list[MemoryLayer]
|
|
57
|
-
MemoryLayerType: TypeAlias = Literal["agent", "user"]
|
|
65
|
+
MemoryLayerType: TypeAlias = Literal["agent", "assistant", "user"]
|
|
58
66
|
|
|
59
67
|
#: Layer types the runtime can mount, in mount order.
|
|
60
|
-
_LAYER_ORDER: tuple[MemoryLayerType, ...] = ("agent", "user")
|
|
68
|
+
_LAYER_ORDER: tuple[MemoryLayerType, ...] = ("agent", "assistant", "user")
|
|
61
69
|
|
|
62
70
|
|
|
63
71
|
def has_agent_memory_layer(memory: MemoryLayers) -> bool:
|
|
@@ -122,23 +130,30 @@ def _normalize_memory_layer(entry: MemoryLayer) -> MemoryLayer:
|
|
|
122
130
|
"modes, and retention are not implemented yet."
|
|
123
131
|
)
|
|
124
132
|
layer_type = mapping.get("type")
|
|
125
|
-
if layer_type
|
|
133
|
+
if layer_type in ("agent", "assistant"):
|
|
126
134
|
if "id" in mapping:
|
|
127
135
|
raise ValueError(
|
|
128
136
|
"define_memory(...) an agent layer takes no `id`: the deployment owns it. "
|
|
129
137
|
'Write `{"type": "agent"}`.'
|
|
138
|
+
if layer_type == "agent"
|
|
139
|
+
else "define_memory(...) an assistant layer takes no `id`: "
|
|
140
|
+
"the runtime resolves it. "
|
|
141
|
+
'Write `{"type": "assistant"}`.'
|
|
130
142
|
)
|
|
131
|
-
layer
|
|
143
|
+
layer = cast("AgentMemoryLayer | AssistantMemoryLayer", {"type": layer_type})
|
|
132
144
|
if "allow" in mapping:
|
|
133
145
|
allow = mapping["allow"]
|
|
134
146
|
if not callable(allow):
|
|
135
|
-
raise ValueError(
|
|
147
|
+
raise ValueError(
|
|
148
|
+
f"define_memory(...) an {layer_type} layer `allow` must be callable."
|
|
149
|
+
)
|
|
136
150
|
layer["allow"] = cast("Callable[[Any], bool | Awaitable[bool]]", allow)
|
|
137
151
|
return layer
|
|
138
152
|
if layer_type == "user":
|
|
139
153
|
return _normalize_user_layer(mapping)
|
|
140
154
|
raise ValueError(
|
|
141
|
-
f
|
|
155
|
+
f"define_memory(...) unknown `scope` entry type {layer_type!r}. "
|
|
156
|
+
'Use "agent", "assistant", or "user".'
|
|
142
157
|
)
|
|
143
158
|
|
|
144
159
|
|
|
@@ -42,12 +42,14 @@ def managed_context_backend(
|
|
|
42
42
|
*,
|
|
43
43
|
mount_agent_memory: bool = False,
|
|
44
44
|
user_memory_backend: BackendProtocol | None = None,
|
|
45
|
+
assistant_memory_backend: BackendProtocol | None = None,
|
|
45
46
|
selected_skills_backend: BackendProtocol | None = None,
|
|
46
47
|
) -> CompositeBackend:
|
|
47
48
|
routes = managed_context_routes(
|
|
48
49
|
context_backend,
|
|
49
50
|
mount_agent_memory=mount_agent_memory,
|
|
50
51
|
user_memory_backend=user_memory_backend,
|
|
52
|
+
assistant_memory_backend=assistant_memory_backend,
|
|
51
53
|
selected_skills_backend=selected_skills_backend,
|
|
52
54
|
)
|
|
53
55
|
default_backend = sandbox_backend if sandbox_backend is not None else state_backend_cls()
|
|
@@ -74,6 +76,7 @@ def managed_context_routes(
|
|
|
74
76
|
*,
|
|
75
77
|
mount_agent_memory: bool = False,
|
|
76
78
|
user_memory_backend: BackendProtocol | None = None,
|
|
79
|
+
assistant_memory_backend: BackendProtocol | None = None,
|
|
77
80
|
selected_skills_backend: BackendProtocol | None = None,
|
|
78
81
|
) -> dict[str, BackendProtocol]:
|
|
79
82
|
routes: dict[str, BackendProtocol] = {
|
|
@@ -92,6 +95,11 @@ def managed_context_routes(
|
|
|
92
95
|
if mount_agent_memory
|
|
93
96
|
else UnmountedMemoryBackend("agent")
|
|
94
97
|
)
|
|
98
|
+
routes["/memories/assistant/"] = (
|
|
99
|
+
MountedPathBackend.directory(assistant_memory_backend, "", "/memories/assistant")
|
|
100
|
+
if assistant_memory_backend is not None
|
|
101
|
+
else UnmountedMemoryBackend("assistant")
|
|
102
|
+
)
|
|
95
103
|
routes["/memories/user/"] = (
|
|
96
104
|
MountedPathBackend.directory(user_memory_backend, "", "/memories/user")
|
|
97
105
|
if user_memory_backend is not None
|
|
@@ -108,7 +116,7 @@ class UnmountedMemoryBackend(BackendProtocol):
|
|
|
108
116
|
route and would fail the whole search on one route's error.
|
|
109
117
|
"""
|
|
110
118
|
|
|
111
|
-
def __init__(self, layer: Literal["agent", "user"]) -> None:
|
|
119
|
+
def __init__(self, layer: Literal["agent", "assistant", "user"]) -> None:
|
|
112
120
|
self._layer = layer
|
|
113
121
|
|
|
114
122
|
def ls(self, path: str = "/") -> LsResult:
|
|
@@ -20,7 +20,12 @@ from managed_deepagents._identity_runtime import (
|
|
|
20
20
|
if TYPE_CHECKING:
|
|
21
21
|
from collections.abc import Callable
|
|
22
22
|
|
|
23
|
-
from managed_deepagents._memory.layers import
|
|
23
|
+
from managed_deepagents._memory.layers import (
|
|
24
|
+
AgentMemoryLayer,
|
|
25
|
+
AssistantMemoryLayer,
|
|
26
|
+
MemoryLayer,
|
|
27
|
+
UserMemoryLayer,
|
|
28
|
+
)
|
|
24
29
|
from managed_deepagents._telemetry.run import UserMemoryDeniedReason
|
|
25
30
|
|
|
26
31
|
|
|
@@ -123,7 +128,7 @@ async def resolve_user_memory_access(
|
|
|
123
128
|
|
|
124
129
|
|
|
125
130
|
async def resolve_agent_memory_access(
|
|
126
|
-
layer: AgentMemoryLayer | None,
|
|
131
|
+
layer: AgentMemoryLayer | AssistantMemoryLayer | None,
|
|
127
132
|
context: object,
|
|
128
133
|
context_schema: object,
|
|
129
134
|
*,
|
|
@@ -52,6 +52,12 @@ def managed_memory_instructions(memory: MemoryLayers) -> str:
|
|
|
52
52
|
Do not save private or caller-specific information here.
|
|
53
53
|
- Its hot file is `/memories/agent/AGENTS.md`."""
|
|
54
54
|
)
|
|
55
|
+
elif layer["type"] == "assistant":
|
|
56
|
+
mounts.append(
|
|
57
|
+
"""- `/memories/assistant/` is shared by callers of this assistant only.
|
|
58
|
+
- Save assistant-specific information here, not private caller information.
|
|
59
|
+
- Its hot file is `/memories/assistant/AGENTS.md`."""
|
|
60
|
+
)
|
|
55
61
|
else:
|
|
56
62
|
mounts.append(
|
|
57
63
|
"""- `/memories/user/` belongs to the current trusted caller.
|
|
@@ -114,10 +120,12 @@ def _load_memory_instructions(
|
|
|
114
120
|
instructions: str,
|
|
115
121
|
load_agent_memory: Callable[[], str | None] | None,
|
|
116
122
|
load_user_memory: Callable[[], str | None] | None,
|
|
123
|
+
load_assistant_memory: Callable[[], str | None] | None,
|
|
117
124
|
) -> str:
|
|
118
125
|
contents: list[str] = []
|
|
119
126
|
for path, load in [
|
|
120
127
|
("/memories/agent/AGENTS.md", load_agent_memory),
|
|
128
|
+
("/memories/assistant/AGENTS.md", load_assistant_memory),
|
|
121
129
|
("/memories/user/AGENTS.md", load_user_memory),
|
|
122
130
|
]:
|
|
123
131
|
content = load() if load else None
|
|
@@ -137,6 +145,7 @@ def create_memory_instructions_middleware(
|
|
|
137
145
|
load_user_memory: Callable[[], str | None] | None = None,
|
|
138
146
|
*,
|
|
139
147
|
load_agent_memory: Callable[[], str | None] | None = None,
|
|
148
|
+
load_assistant_memory: Callable[[], str | None] | None = None,
|
|
140
149
|
) -> AgentMiddleware[AgentState[object], None, object]:
|
|
141
150
|
"""Load hot memory once for this run and inject it per call, outside thread state."""
|
|
142
151
|
from langchain.agents.middleware.types import AgentMiddleware, AgentState # noqa: PLC0415
|
|
@@ -154,7 +163,7 @@ def create_memory_instructions_middleware(
|
|
|
154
163
|
loaded = cached.get(run_id)
|
|
155
164
|
if loaded is None:
|
|
156
165
|
loaded = _load_memory_instructions(
|
|
157
|
-
instructions, load_agent_memory, load_user_memory
|
|
166
|
+
instructions, load_agent_memory, load_user_memory, load_assistant_memory
|
|
158
167
|
)
|
|
159
168
|
cached[run_id] = loaded
|
|
160
169
|
while len(cached) > _RUNS_KEPT:
|
managed_deepagents/_run_input.py
CHANGED
|
@@ -28,6 +28,7 @@ from managed_deepagents._channels.delivery import (
|
|
|
28
28
|
from managed_deepagents._channels.run_output import RunOutput, _current_output
|
|
29
29
|
from managed_deepagents._identity_runtime import _field
|
|
30
30
|
from managed_deepagents._managed_thread import RunThread, _current_thread, build_run_thread
|
|
31
|
+
from managed_deepagents._memory.assistant_memory import APPROVED_ASSISTANT
|
|
31
32
|
from managed_deepagents._memory.async_util import await_if_needed
|
|
32
33
|
from managed_deepagents._memory.user_memory import APPROVED_USER
|
|
33
34
|
from managed_deepagents._telemetry.otel import (
|
|
@@ -74,17 +75,19 @@ class ManagedCompiledAgent(CompiledStateGraph[Any, Any, Any, Any]):
|
|
|
74
75
|
"""
|
|
75
76
|
|
|
76
77
|
approved_user: str | None = None
|
|
78
|
+
approved_assistant: str | None = None
|
|
77
79
|
|
|
78
80
|
def copy(self, update: dict[str, Any] | None = None) -> Self:
|
|
79
81
|
"""``Pregel.copy``, also keeping ``approved_user``, which ``__init__`` doesn't take."""
|
|
80
82
|
attrs = {
|
|
81
83
|
key: value
|
|
82
84
|
for key, value in self.__dict__.items()
|
|
83
|
-
if key not in ("__orig_class__", "approved_user")
|
|
85
|
+
if key not in ("__orig_class__", "approved_user", "approved_assistant")
|
|
84
86
|
}
|
|
85
87
|
attrs.update(update or {})
|
|
86
88
|
copied = self.__class__(**attrs)
|
|
87
89
|
copied.approved_user = self.approved_user
|
|
90
|
+
copied.approved_assistant = self.approved_assistant
|
|
88
91
|
return copied
|
|
89
92
|
|
|
90
93
|
def stream(
|
|
@@ -104,7 +107,15 @@ class ManagedCompiledAgent(CompiledStateGraph[Any, Any, Any, Any]):
|
|
|
104
107
|
iterator = super().stream(input, config, context=context, **kwargs)
|
|
105
108
|
try:
|
|
106
109
|
while True:
|
|
107
|
-
tokens = _enter_step(
|
|
110
|
+
tokens = _enter_step(
|
|
111
|
+
binding,
|
|
112
|
+
routing,
|
|
113
|
+
thread,
|
|
114
|
+
log,
|
|
115
|
+
output,
|
|
116
|
+
self.approved_user,
|
|
117
|
+
self.approved_assistant,
|
|
118
|
+
)
|
|
108
119
|
try:
|
|
109
120
|
item = next(iterator)
|
|
110
121
|
except StopIteration:
|
|
@@ -143,7 +154,15 @@ class ManagedCompiledAgent(CompiledStateGraph[Any, Any, Any, Any]):
|
|
|
143
154
|
iterator = super().astream(input, config, context=context, **kwargs)
|
|
144
155
|
try:
|
|
145
156
|
while True:
|
|
146
|
-
tokens = _enter_step(
|
|
157
|
+
tokens = _enter_step(
|
|
158
|
+
binding,
|
|
159
|
+
routing,
|
|
160
|
+
thread,
|
|
161
|
+
log,
|
|
162
|
+
output,
|
|
163
|
+
self.approved_user,
|
|
164
|
+
self.approved_assistant,
|
|
165
|
+
)
|
|
147
166
|
try:
|
|
148
167
|
item = await anext(iterator)
|
|
149
168
|
except StopAsyncIteration:
|
|
@@ -300,6 +319,7 @@ def run_log_context(defaults: RunnableConfig | None, config: RunnableConfig | No
|
|
|
300
319
|
_INPUT = {"source": INPUT_SOURCE}
|
|
301
320
|
|
|
302
321
|
_StepTokens = tuple[
|
|
322
|
+
Token[str | None],
|
|
303
323
|
Token[str | None],
|
|
304
324
|
Token[ChannelBinding | None],
|
|
305
325
|
Token[Mapping[str, object] | None],
|
|
@@ -316,10 +336,12 @@ def _enter_step(
|
|
|
316
336
|
log: LogContext,
|
|
317
337
|
output: RunOutput | None,
|
|
318
338
|
approved_user: str | None,
|
|
339
|
+
approved_assistant: str | None = None,
|
|
319
340
|
) -> _StepTokens:
|
|
320
341
|
return (
|
|
321
342
|
# A nested managed graph has none of its own and keeps its parent's.
|
|
322
343
|
APPROVED_USER.set(approved_user or APPROVED_USER.get()),
|
|
344
|
+
APPROVED_ASSISTANT.set(approved_assistant or APPROVED_ASSISTANT.get()),
|
|
323
345
|
_current_channel.set(binding),
|
|
324
346
|
_current_routing.set(routing),
|
|
325
347
|
_current_thread.set(thread),
|
|
@@ -329,12 +351,13 @@ def _enter_step(
|
|
|
329
351
|
|
|
330
352
|
|
|
331
353
|
def _exit_step(tokens: _StepTokens) -> None:
|
|
332
|
-
approved, channel, routing, thread, log, output = tokens
|
|
354
|
+
approved, assistant, channel, routing, thread, log, output = tokens
|
|
333
355
|
_current_output.reset(output)
|
|
334
356
|
exit_log_context(log)
|
|
335
357
|
_current_thread.reset(thread)
|
|
336
358
|
_current_routing.reset(routing)
|
|
337
359
|
_current_channel.reset(channel)
|
|
360
|
+
APPROVED_ASSISTANT.reset(assistant)
|
|
338
361
|
APPROVED_USER.reset(approved)
|
|
339
362
|
|
|
340
363
|
|
|
@@ -17,6 +17,7 @@ from urllib.parse import quote
|
|
|
17
17
|
from langchain_core.runnables.config import var_child_runnable_config
|
|
18
18
|
from langgraph.errors import GraphInterrupt
|
|
19
19
|
|
|
20
|
+
from managed_deepagents._agent_auth_http import CredentialStoreUnavailableError
|
|
20
21
|
from managed_deepagents._connections import (
|
|
21
22
|
ConnectionNotFoundError,
|
|
22
23
|
ConnectionReference,
|
|
@@ -124,7 +125,11 @@ async def resolve_sandbox_proxy_config(
|
|
|
124
125
|
headers.append({**header, "value": header_value, "type": "opaque"})
|
|
125
126
|
rules.append({**rule, "headers": headers} if "headers" in rule else dict(rule))
|
|
126
127
|
return {**cast("dict[str, object]", config), "rules": rules}
|
|
127
|
-
except (
|
|
128
|
+
except (
|
|
129
|
+
ConnectionNotFoundError,
|
|
130
|
+
CredentialAuthorizationRequiredError,
|
|
131
|
+
CredentialStoreUnavailableError,
|
|
132
|
+
):
|
|
128
133
|
raise
|
|
129
134
|
except Exception as error:
|
|
130
135
|
if isinstance(error, GraphInterrupt):
|
|
@@ -237,6 +242,13 @@ class SandboxProxyConfigSync:
|
|
|
237
242
|
self._hashes[name] = digest
|
|
238
243
|
|
|
239
244
|
|
|
245
|
+
def sandbox_has_proxy_connections(sandbox: SandboxDefinition | None) -> bool:
|
|
246
|
+
"""Whether the sandbox proxy config resolves any connection through Agent Auth."""
|
|
247
|
+
return sandbox is not None and bool(
|
|
248
|
+
validate_and_collect_sandbox_proxy_config_references(sandbox.options.get("proxy_config"))
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
240
252
|
def sandbox_credential_consumers(sandbox: SandboxDefinition | None) -> list[CredentialConsumer]:
|
|
241
253
|
from managed_deepagents._credential_gate import CredentialConsumer # noqa: PLC0415
|
|
242
254
|
|
|
@@ -25,7 +25,7 @@ RunOutcome = Literal["success", "failure", "interrupted", "cancelled"]
|
|
|
25
25
|
#: Whether the run is an agent's own or one of its async subagents'.
|
|
26
26
|
SubagentRole = Literal["lead", "async_subagent"]
|
|
27
27
|
|
|
28
|
-
MemoryLayerType = Literal["agent", "user"]
|
|
28
|
+
MemoryLayerType = Literal["agent", "assistant", "user"]
|
|
29
29
|
|
|
30
30
|
#: ``resolve_user_memory_access`` returns the same ``None`` for several distinct
|
|
31
31
|
#: denials, so adoption measured from the presence of ``memory.py`` overcounts.
|
|
@@ -15,7 +15,7 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
from collections.abc import Awaitable, Callable, Sequence
|
|
17
17
|
from dataclasses import dataclass
|
|
18
|
-
from typing import ClassVar, Generic, Literal, Protocol, TypedDict
|
|
18
|
+
from typing import ClassVar, Generic, Literal, Protocol, TypedDict, cast
|
|
19
19
|
|
|
20
20
|
from typing_extensions import TypeVar
|
|
21
21
|
|
|
@@ -39,6 +39,7 @@ __all__ = [
|
|
|
39
39
|
|
|
40
40
|
ContextT = TypeVar("ContextT", default=ManagedRunContext)
|
|
41
41
|
AgentContextT = TypeVar("AgentContextT", default=ManagedRunContext)
|
|
42
|
+
AssistantContextT = TypeVar("AssistantContextT", default=ManagedRunContext)
|
|
42
43
|
UserContextT = TypeVar("UserContextT", default=ManagedRunContext)
|
|
43
44
|
|
|
44
45
|
|
|
@@ -46,7 +47,7 @@ UserContextT = TypeVar("UserContextT", default=ManagedRunContext)
|
|
|
46
47
|
class MemoryLayer(Generic[ContextT]):
|
|
47
48
|
"""Enable a memory layer, with an optional per-run context policy.
|
|
48
49
|
|
|
49
|
-
Without ``allow``, agent memory
|
|
50
|
+
Without ``allow``, agent and assistant memory are available to all callers; user memory
|
|
50
51
|
is available to trusted people in managed Slack one-to-one DMs.
|
|
51
52
|
Verified Studio users always have user memory access without running its policy.
|
|
52
53
|
"""
|
|
@@ -97,7 +98,7 @@ class MemoryDefinition:
|
|
|
97
98
|
#: Reserved keywords from adjacent designs. Naming them keeps a hopeful guess
|
|
98
99
|
#: from reading as an unknown typo, and keeps the launch surface one decision wide.
|
|
99
100
|
_RESERVED_KEYWORDS: dict[str, str] = {
|
|
100
|
-
"layers": ("Declare independent `agent` and `user` layers."),
|
|
101
|
+
"layers": ("Declare independent `agent`, `assistant`, and `user` layers."),
|
|
101
102
|
"user_memory": "Use `user=MemoryLayer()` to enable caller-scoped memory.",
|
|
102
103
|
"workspace_memory": "Workspace memory is not designed yet.",
|
|
103
104
|
"organization_memory": "Organization-scoped memory is not supported.",
|
|
@@ -115,11 +116,12 @@ _RESERVED_KEYWORDS: dict[str, str] = {
|
|
|
115
116
|
def define_memory(
|
|
116
117
|
*,
|
|
117
118
|
agent: MemoryLayer[AgentContextT] | None = None,
|
|
119
|
+
assistant: MemoryLayer[AssistantContextT] | None = None,
|
|
118
120
|
user: MemoryLayer[UserContextT] | None = None,
|
|
119
121
|
scope: ResolvedMemoryLayer | Sequence[ResolvedMemoryLayer] | None = None,
|
|
120
122
|
**kwargs: object,
|
|
121
123
|
) -> MemoryDefinition:
|
|
122
|
-
"""Declare independent agent and user memory layers.
|
|
124
|
+
"""Declare independent agent, assistant, and user memory layers.
|
|
123
125
|
|
|
124
126
|
Example::
|
|
125
127
|
|
|
@@ -129,25 +131,28 @@ def define_memory(
|
|
|
129
131
|
)
|
|
130
132
|
|
|
131
133
|
Omitted layers are disabled. Each enabled layer mounts a read/write tree at
|
|
132
|
-
``/memories/agent
|
|
134
|
+
``/memories/agent/``, ``/memories/assistant/``, or ``/memories/user/``,
|
|
135
|
+
with ``AGENTS.md`` as hot memory.
|
|
133
136
|
An optional sync or async ``allow(context)`` replaces that layer's default
|
|
134
137
|
policy. The runtime evaluates it once per run, before mounting storage.
|
|
135
138
|
Verified Studio users skip the user memory policy and always have access.
|
|
136
139
|
User memory always requires a trusted person, regardless of its policy.
|
|
137
140
|
|
|
138
141
|
``scope`` accepts the legacy layer declarations. Do not combine it with
|
|
139
|
-
``agent`` or ``user``.
|
|
142
|
+
``agent``, ``assistant``, or ``user``.
|
|
140
143
|
"""
|
|
141
144
|
_assert_keywords(kwargs)
|
|
142
|
-
if scope is not None and (
|
|
143
|
-
raise ValueError(
|
|
145
|
+
if scope is not None and any(layer is not None for layer in (agent, assistant, user)):
|
|
146
|
+
raise ValueError(
|
|
147
|
+
"define_memory(...) cannot mix `scope` with `agent`, `assistant`, or `user`."
|
|
148
|
+
)
|
|
144
149
|
layers: MemoryLayers = []
|
|
145
|
-
for name, layer in (("agent", agent), ("user", user)):
|
|
150
|
+
for name, layer in (("agent", agent), ("assistant", assistant), ("user", user)):
|
|
146
151
|
if layer is None:
|
|
147
152
|
continue
|
|
148
153
|
if not isinstance(layer, MemoryLayer):
|
|
149
154
|
raise TypeError(f"define_memory(...) `{name}` must be a MemoryLayer.")
|
|
150
|
-
resolved
|
|
155
|
+
resolved = cast("ResolvedMemoryLayer", {"type": name})
|
|
151
156
|
if layer.allow is not None:
|
|
152
157
|
resolved["allow"] = layer.allow
|
|
153
158
|
layers.append(resolved)
|
|
@@ -163,11 +168,12 @@ def _assert_keywords(kwargs: dict[str, object]) -> None:
|
|
|
163
168
|
if key in kwargs:
|
|
164
169
|
raise ValueError(
|
|
165
170
|
f"define_memory(...) `{key}` is not supported. {reason} "
|
|
166
|
-
"Use `agent=MemoryLayer()`, `
|
|
167
|
-
"Omit
|
|
171
|
+
"Use `agent=MemoryLayer()`, `assistant=MemoryLayer()`, or `user=MemoryLayer()`. "
|
|
172
|
+
"Omit all layers to keep no memory."
|
|
168
173
|
)
|
|
169
174
|
if kwargs:
|
|
170
175
|
unknown = ", ".join(sorted(kwargs))
|
|
171
176
|
raise ValueError(
|
|
172
|
-
f"define_memory(...) unknown option(s): {unknown}.
|
|
177
|
+
f"define_memory(...) unknown option(s): {unknown}. "
|
|
178
|
+
"Valid options: agent, assistant, user, scope."
|
|
173
179
|
)
|
managed_deepagents/runtime.py
CHANGED
|
@@ -134,6 +134,7 @@ from managed_deepagents._memory import (
|
|
|
134
134
|
from managed_deepagents._memory import (
|
|
135
135
|
managed_selected_skills_backend as _managed_selected_skills_backend,
|
|
136
136
|
)
|
|
137
|
+
from managed_deepagents._memory.assistant_memory import AssistantMemoryBackend
|
|
137
138
|
from managed_deepagents._memory.async_util import await_if_needed as _await_if_needed
|
|
138
139
|
from managed_deepagents._memory.context_io import (
|
|
139
140
|
download_context_file as _download_context_file,
|
|
@@ -808,6 +809,11 @@ async def compile_managed_agent_async(
|
|
|
808
809
|
`async_subagent` to build that async subagent's own graph instead.
|
|
809
810
|
"""
|
|
810
811
|
timing = GraphBuildTiming()
|
|
812
|
+
trusted_assistant_id = None
|
|
813
|
+
if runtime is not None and runtime.execution_runtime is not None:
|
|
814
|
+
candidate = (config or {}).get("metadata", {}).get("assistant_id")
|
|
815
|
+
if isinstance(candidate, str) and candidate.strip():
|
|
816
|
+
trusted_assistant_id = candidate.strip()
|
|
811
817
|
if runtime is not None:
|
|
812
818
|
execution = runtime.execution_runtime
|
|
813
819
|
is_run = execution is not None
|
|
@@ -856,6 +862,7 @@ async def compile_managed_agent_async(
|
|
|
856
862
|
skip_factory_inspection_tools=factory_inspection,
|
|
857
863
|
subagent_role="lead" if async_subagent is None else "async_subagent",
|
|
858
864
|
factory_entry=factory_entry,
|
|
865
|
+
trusted_assistant_id=trusted_assistant_id,
|
|
859
866
|
timing=timing,
|
|
860
867
|
cached_entry=entry if isinstance(entry, (CachedAgent, DeepAgentDefinition)) else None,
|
|
861
868
|
cached_graph="lead" if async_subagent is None else f"subagent:{async_subagent}",
|
|
@@ -915,6 +922,7 @@ async def _compile_resolved_managed_agent_async(
|
|
|
915
922
|
factory_entry: bool = False,
|
|
916
923
|
subagent_role: SubagentRole = "lead",
|
|
917
924
|
timing: GraphBuildTiming,
|
|
925
|
+
trusted_assistant_id: str | None = None,
|
|
918
926
|
cached_entry: object | None = None,
|
|
919
927
|
cached_graph: str | None = None,
|
|
920
928
|
cached_digest: str | None = None,
|
|
@@ -983,6 +991,7 @@ async def _compile_resolved_managed_agent_async(
|
|
|
983
991
|
else context_schema
|
|
984
992
|
)
|
|
985
993
|
allow_agent = False
|
|
994
|
+
allow_assistant = False
|
|
986
995
|
user_access = UserMemoryAccess(denied_reason="no_context")
|
|
987
996
|
if is_run:
|
|
988
997
|
agent_layer = next(
|
|
@@ -993,6 +1002,14 @@ async def _compile_resolved_managed_agent_async(
|
|
|
993
1002
|
if policy_schema is ManagedChannelContext:
|
|
994
1003
|
policy_context = _with_thread_origin(policy_context, config)
|
|
995
1004
|
allow_agent = await resolve_agent_memory_access(agent_layer, policy_context, policy_schema)
|
|
1005
|
+
assistant_layer = next(
|
|
1006
|
+
(layer for layer in declared_memory_layers if layer["type"] == "assistant"), None
|
|
1007
|
+
)
|
|
1008
|
+
allow_assistant = await resolve_agent_memory_access(
|
|
1009
|
+
assistant_layer, policy_context, policy_schema
|
|
1010
|
+
)
|
|
1011
|
+
if allow_assistant and trusted_assistant_id is None:
|
|
1012
|
+
raise ValueError("Assistant memory requires a trusted runtime assistant identity")
|
|
996
1013
|
user_access = await resolve_user_memory_access(
|
|
997
1014
|
user_memory_layer(declared_memory_layers),
|
|
998
1015
|
config,
|
|
@@ -1022,7 +1039,7 @@ async def _compile_resolved_managed_agent_async(
|
|
|
1022
1039
|
# call and checks them against the user this call was approved for
|
|
1023
1040
|
# (APPROVED_USER), so one graph serves every user. Reads have no caller, so
|
|
1024
1041
|
# their policy is None and they can reuse any cached graph.
|
|
1025
|
-
policy = (allow_agent, user_access.user_id is not None) if is_run else None
|
|
1042
|
+
policy = (allow_agent, allow_assistant, user_access.user_id is not None) if is_run else None
|
|
1026
1043
|
|
|
1027
1044
|
async def compile_graph() -> _BuiltGraph:
|
|
1028
1045
|
agent, configuration = await asyncio.to_thread(
|
|
@@ -1034,6 +1051,7 @@ async def _compile_resolved_managed_agent_async(
|
|
|
1034
1051
|
None if key is not None else config,
|
|
1035
1052
|
**options,
|
|
1036
1053
|
allow_agent=allow_agent,
|
|
1054
|
+
allow_assistant=allow_assistant,
|
|
1037
1055
|
user_access=user_access,
|
|
1038
1056
|
declared_memory_layers=declared_memory_layers,
|
|
1039
1057
|
inspection=not is_run,
|
|
@@ -1064,6 +1082,7 @@ async def _compile_resolved_managed_agent_async(
|
|
|
1064
1082
|
report_telemetry=report_telemetry,
|
|
1065
1083
|
started_monotonic_ms=started_monotonic_ms,
|
|
1066
1084
|
user_access=user_access,
|
|
1085
|
+
approved_assistant=trusted_assistant_id if allow_assistant else None,
|
|
1067
1086
|
)
|
|
1068
1087
|
|
|
1069
1088
|
|
|
@@ -1076,6 +1095,7 @@ def _for_call(
|
|
|
1076
1095
|
report_telemetry: bool,
|
|
1077
1096
|
started_monotonic_ms: float,
|
|
1078
1097
|
user_access: UserMemoryAccess | None = None,
|
|
1098
|
+
approved_assistant: str | None = None,
|
|
1079
1099
|
) -> CompiledAgent:
|
|
1080
1100
|
"""Prepare a compiled graph for this call: telemetry and this run's config.
|
|
1081
1101
|
|
|
@@ -1131,13 +1151,14 @@ def _for_call(
|
|
|
1131
1151
|
# The user this run may reach user memory as: from the run's resolved
|
|
1132
1152
|
# access, never from anything the caller sends.
|
|
1133
1153
|
agent.approved_user = user_access.user_id
|
|
1154
|
+
agent.approved_assistant = approved_assistant
|
|
1134
1155
|
return agent
|
|
1135
1156
|
|
|
1136
1157
|
|
|
1137
1158
|
# (entry, graph, params digest, compile options); see _compile_resolved_managed_agent_async.
|
|
1138
1159
|
_GraphKey = tuple[object, str, str, tuple[object, ...]]
|
|
1139
|
-
# (agent
|
|
1140
|
-
_Policy = tuple[bool, bool] | None
|
|
1160
|
+
# (agent, assistant, user memory allowed) for a run; None for a read.
|
|
1161
|
+
_Policy = tuple[bool, bool, bool] | None
|
|
1141
1162
|
|
|
1142
1163
|
|
|
1143
1164
|
@dataclass(frozen=True)
|
|
@@ -1364,6 +1385,7 @@ def _compile_managed_agent(
|
|
|
1364
1385
|
trial_root_dir: str | None = None,
|
|
1365
1386
|
user_access: UserMemoryAccess,
|
|
1366
1387
|
allow_agent: bool,
|
|
1388
|
+
allow_assistant: bool,
|
|
1367
1389
|
declared_memory_layers: MemoryLayers,
|
|
1368
1390
|
inspection: bool = False,
|
|
1369
1391
|
skip_factory_inspection_tools: bool = False,
|
|
@@ -1375,7 +1397,6 @@ def _compile_managed_agent(
|
|
|
1375
1397
|
|
|
1376
1398
|
Per-call telemetry and config are applied later by ``_for_call``.
|
|
1377
1399
|
"""
|
|
1378
|
-
allowed_user_id = user_access.user_id
|
|
1379
1400
|
# Resolution + thread/store scope run in the generated custom-auth handler
|
|
1380
1401
|
# (``build_managed_auth``). When identity is declared, the seam also surfaces
|
|
1381
1402
|
# ``runtime.server_info.principal`` to authored + connector tools (below),
|
|
@@ -1439,8 +1460,9 @@ def _compile_managed_agent(
|
|
|
1439
1460
|
)
|
|
1440
1461
|
mounted_memory: MemoryLayers = []
|
|
1441
1462
|
user_memory_backend: UserMemoryBackend | None = None
|
|
1463
|
+
assistant_memory_backend: AssistantMemoryBackend | None = None
|
|
1442
1464
|
if context is not None and live_context_backend is not None:
|
|
1443
|
-
mounted_memory, user_memory_backend = _apply_managed_context(
|
|
1465
|
+
mounted_memory, user_memory_backend, assistant_memory_backend = _apply_managed_context(
|
|
1444
1466
|
merged,
|
|
1445
1467
|
context_backend=live_context_backend,
|
|
1446
1468
|
filesystem_root=context.filesystem_root,
|
|
@@ -1450,7 +1472,8 @@ def _compile_managed_agent(
|
|
|
1450
1472
|
memory_layers=declared_memory_layers,
|
|
1451
1473
|
selected_skills_backend=selected_skills_backend,
|
|
1452
1474
|
allow_agent=allow_agent,
|
|
1453
|
-
allowed_user_id=
|
|
1475
|
+
allowed_user_id=user_access.user_id,
|
|
1476
|
+
allow_assistant=allow_assistant,
|
|
1454
1477
|
)
|
|
1455
1478
|
elif sandbox_backend is not None:
|
|
1456
1479
|
merged["backend"] = sandbox_backend
|
|
@@ -1528,6 +1551,7 @@ def _compile_managed_agent(
|
|
|
1528
1551
|
merged,
|
|
1529
1552
|
mounted_memory,
|
|
1530
1553
|
user_memory_backend,
|
|
1554
|
+
assistant_memory_backend=assistant_memory_backend,
|
|
1531
1555
|
agent_memory_backend=live_context_backend
|
|
1532
1556
|
if has_agent_memory_layer(mounted_memory)
|
|
1533
1557
|
else None,
|
|
@@ -1851,7 +1875,8 @@ def _apply_managed_context(
|
|
|
1851
1875
|
selected_skills_backend: SelectedSkillsBackend | None,
|
|
1852
1876
|
allowed_user_id: str | None,
|
|
1853
1877
|
allow_agent: bool,
|
|
1854
|
-
|
|
1878
|
+
allow_assistant: bool = False,
|
|
1879
|
+
) -> tuple[MemoryLayers, UserMemoryBackend | None, AssistantMemoryBackend | None]:
|
|
1855
1880
|
"""Wire system prompt, backend routes, permissions, and hot memory.
|
|
1856
1881
|
|
|
1857
1882
|
Return the mounted layers and the caller backend used to load user hot
|
|
@@ -1863,7 +1888,13 @@ def _apply_managed_context(
|
|
|
1863
1888
|
memory_layers = [
|
|
1864
1889
|
layer
|
|
1865
1890
|
for layer in memory_layers
|
|
1866
|
-
if (
|
|
1891
|
+
if (
|
|
1892
|
+
allow_agent
|
|
1893
|
+
if layer["type"] == "agent"
|
|
1894
|
+
else allow_assistant
|
|
1895
|
+
if layer["type"] == "assistant"
|
|
1896
|
+
else allowed_user_id is not None
|
|
1897
|
+
)
|
|
1867
1898
|
]
|
|
1868
1899
|
declared_user_layer = user_memory_layer(memory_layers)
|
|
1869
1900
|
user_memory_backend = (
|
|
@@ -1878,6 +1909,13 @@ def _apply_managed_context(
|
|
|
1878
1909
|
if declared_user_layer is not None
|
|
1879
1910
|
else None
|
|
1880
1911
|
)
|
|
1912
|
+
assistant_memory_backend = (
|
|
1913
|
+
AssistantMemoryBackend(
|
|
1914
|
+
deploy_handle=context_repo or "local", filesystem_root=filesystem_root
|
|
1915
|
+
)
|
|
1916
|
+
if any(layer["type"] == "assistant" for layer in memory_layers)
|
|
1917
|
+
else None
|
|
1918
|
+
)
|
|
1881
1919
|
merged["backend"] = _managed_context_backend(
|
|
1882
1920
|
context_backend,
|
|
1883
1921
|
sandbox_backend,
|
|
@@ -1885,6 +1923,7 @@ def _apply_managed_context(
|
|
|
1885
1923
|
StateBackend,
|
|
1886
1924
|
mount_agent_memory=has_agent_memory_layer(memory_layers),
|
|
1887
1925
|
user_memory_backend=user_memory_backend,
|
|
1926
|
+
assistant_memory_backend=assistant_memory_backend,
|
|
1888
1927
|
selected_skills_backend=selected_skills_backend,
|
|
1889
1928
|
)
|
|
1890
1929
|
# Sandbox + FilesystemPermission cannot coexist at execute() time: deepagents
|
|
@@ -1897,7 +1936,7 @@ def _apply_managed_context(
|
|
|
1897
1936
|
merged.get("permissions"),
|
|
1898
1937
|
FilesystemPermission,
|
|
1899
1938
|
)
|
|
1900
|
-
return memory_layers, user_memory_backend
|
|
1939
|
+
return memory_layers, user_memory_backend, assistant_memory_backend
|
|
1901
1940
|
|
|
1902
1941
|
|
|
1903
1942
|
def _declared_memory_layers(memory: MemoryDefinitionLike | None) -> MemoryLayers:
|
|
@@ -2128,8 +2167,12 @@ def _prepend_credential_gate_middleware(
|
|
|
2128
2167
|
)
|
|
2129
2168
|
from managed_deepagents._credential_gate import ( # noqa: PLC0415
|
|
2130
2169
|
create_credential_gate_middleware,
|
|
2170
|
+
create_credential_outage_middleware,
|
|
2171
|
+
)
|
|
2172
|
+
from managed_deepagents._sandbox_proxy import ( # noqa: PLC0415
|
|
2173
|
+
sandbox_credential_consumers,
|
|
2174
|
+
sandbox_has_proxy_connections,
|
|
2131
2175
|
)
|
|
2132
|
-
from managed_deepagents._sandbox_proxy import sandbox_credential_consumers # noqa: PLC0415
|
|
2133
2176
|
|
|
2134
2177
|
gate = create_credential_gate_middleware(
|
|
2135
2178
|
[
|
|
@@ -2138,7 +2181,9 @@ def _prepend_credential_gate_middleware(
|
|
|
2138
2181
|
]
|
|
2139
2182
|
)
|
|
2140
2183
|
if gate is None:
|
|
2141
|
-
|
|
2184
|
+
if not sandbox_has_proxy_connections(sandbox):
|
|
2185
|
+
return
|
|
2186
|
+
gate = create_credential_outage_middleware()
|
|
2142
2187
|
middleware_value = merged.get("middleware")
|
|
2143
2188
|
existing = (
|
|
2144
2189
|
list(cast("Iterable[object]", middleware_value)) if middleware_value is not None else []
|
|
@@ -2152,6 +2197,7 @@ def _append_memory_instructions_middleware(
|
|
|
2152
2197
|
user_memory_backend: UserMemoryBackend | None = None,
|
|
2153
2198
|
*,
|
|
2154
2199
|
agent_memory_backend: BackendProtocol | None = None,
|
|
2200
|
+
assistant_memory_backend: BackendProtocol | None = None,
|
|
2155
2201
|
) -> None:
|
|
2156
2202
|
"""Replace native memory in its slot after prompt caching, including in forks."""
|
|
2157
2203
|
from managed_deepagents._memory_instructions import ( # noqa: PLC0415
|
|
@@ -2172,6 +2218,11 @@ def _append_memory_instructions_middleware(
|
|
|
2172
2218
|
(lambda: _download_context_file(user_memory_backend, "/AGENTS.md"))
|
|
2173
2219
|
if user_memory_backend is not None
|
|
2174
2220
|
else None,
|
|
2221
|
+
load_assistant_memory=(
|
|
2222
|
+
lambda: _download_context_file(assistant_memory_backend, "/AGENTS.md")
|
|
2223
|
+
)
|
|
2224
|
+
if assistant_memory_backend is not None
|
|
2225
|
+
else None,
|
|
2175
2226
|
load_agent_memory=(
|
|
2176
2227
|
lambda: _download_context_file(agent_memory_backend, "/memories/agent/AGENTS.md")
|
|
2177
2228
|
)
|
{managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: managed-deepagents
|
|
3
|
-
Version: 0.10.4.
|
|
3
|
+
Version: 0.10.4.dev4
|
|
4
4
|
Summary: Managed Deep Agents — the define_deep_agent authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.
|
|
5
5
|
Author: LangChain
|
|
6
6
|
License: MIT
|
|
@@ -220,19 +220,24 @@ connections or user memory. To act for many end users from one server, use a
|
|
|
220
220
|
trusted backend or validated-token identity instead.
|
|
221
221
|
|
|
222
222
|
On deploy, Context Hub stores harness files (`instructions.md`, `skills/**`). A
|
|
223
|
-
root `memory.py` enables agent and user memory independently:
|
|
223
|
+
root `memory.py` enables agent, assistant, and user memory independently:
|
|
224
224
|
|
|
225
225
|
```python
|
|
226
226
|
from managed_deepagents import MemoryLayer, define_memory
|
|
227
227
|
|
|
228
228
|
memory = define_memory(
|
|
229
229
|
agent=MemoryLayer(),
|
|
230
|
+
assistant=MemoryLayer(),
|
|
230
231
|
user=MemoryLayer(),
|
|
231
232
|
)
|
|
232
233
|
```
|
|
233
234
|
|
|
234
235
|
Omit a layer to disable it. A layer with no `allow` callback uses its default
|
|
235
236
|
policy. Agent memory is shared across callers and is available by default.
|
|
237
|
+
Assistant memory is available by default and shared only by runs of the same
|
|
238
|
+
assistant in this deployment. It requires the trusted assistant identity supplied
|
|
239
|
+
by Agent Server; missing identity fails the run instead of using shared memory.
|
|
240
|
+
Neither authored context nor a custom key callback can select another assistant.
|
|
236
241
|
User memory requires a trusted person and defaults to managed Slack one-to-one
|
|
237
242
|
DMs (the original provider event has `channel_type == "im"`). Shared
|
|
238
243
|
conversations, missing event data, and direct API runs get no user mount unless
|
|
@@ -272,17 +277,20 @@ the run. If the context cannot satisfy the policy schema, MDA denies that layer
|
|
|
272
277
|
without calling its policy. An error from the callback still fails the run.
|
|
273
278
|
User policies cannot grant access to another
|
|
274
279
|
person's memory or grant user memory to a service principal. Build, schema, and
|
|
275
|
-
state inspection do not call
|
|
280
|
+
state inspection do not call memory policies.
|
|
276
281
|
|
|
277
|
-
The legacy `scope` option remains supported. Do not combine it with `agent` or
|
|
282
|
+
The legacy `scope` option remains supported. Do not combine it with `agent`, `assistant`, or
|
|
278
283
|
`user`.
|
|
279
284
|
|
|
280
|
-
|
|
281
|
-
model
|
|
285
|
+
Permitted hot memory is loaded once per run, on the first model call, and reused
|
|
286
|
+
for subsequent model calls. It is not saved in thread state. This keeps the graph structure
|
|
282
287
|
stable and prevents a later denied run from loading saved memory. A missing
|
|
283
288
|
hot file stays empty until the first memory write.
|
|
284
289
|
|
|
285
|
-
The agent layer is mounted at `/memories/agent/`. The
|
|
290
|
+
The agent layer is mounted at `/memories/agent/`. The assistant layer mounts
|
|
291
|
+
`/memories/assistant/` from an opaque per-deployment, per-assistant Context Hub repo.
|
|
292
|
+
Assistant memory is separate from deployment-shared agent memory and per-person
|
|
293
|
+
user memory. The user layer requires
|
|
286
294
|
`identity.py` and is mounted from an opaque per-user Context Hub repo at
|
|
287
295
|
`/memories/user/`, keyed on the trusted caller principal. Each mount's
|
|
288
296
|
`AGENTS.md` is injected every turn; other files are read on demand. Deploy never
|
{managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/RECORD
RENAMED
|
@@ -11,7 +11,7 @@ managed_deepagents/_connection_authorization.py,sha256=AnX7CRtP59RWsNmzzt7BoVqX8
|
|
|
11
11
|
managed_deepagents/_connections.py,sha256=BW4vTkPxJDasss-WoRJawcM-kU7OeYSzchHL4ovek70,25829
|
|
12
12
|
managed_deepagents/_connector.py,sha256=s9FTVzs130NOhHYokBgQa6VWy47srUKp2lC56XoY9as,8620
|
|
13
13
|
managed_deepagents/_cors.py,sha256=WAlD_PgLFVAN1BAQaYU44DKctAJk4xQnFZ0I-9EwMng,7814
|
|
14
|
-
managed_deepagents/_credential_gate.py,sha256=
|
|
14
|
+
managed_deepagents/_credential_gate.py,sha256=_ntdBar15t6BjDf6icXu8kNt513tziP1dEHPQFdzmXo,29086
|
|
15
15
|
managed_deepagents/_eval_filesystem.py,sha256=_oRR0CUzpO7XND2JkkNUZH63m5kwxmGcR7cfqfFO378,8768
|
|
16
16
|
managed_deepagents/_extension.py,sha256=MqCWS4AGxiURPtLlA2y_tWKdRL8Zu1-VZyQ6Q3HDgzc,5315
|
|
17
17
|
managed_deepagents/_graph_build_timing.py,sha256=ritnkUzuKQ4-S00bzFB9-S6DtZkl9xslQVh0enVcQag,4996
|
|
@@ -29,12 +29,12 @@ managed_deepagents/_managed_composition.py,sha256=9GVH9Vl5YKx7lMx6Tz-ajastzl1NKy
|
|
|
29
29
|
managed_deepagents/_managed_middleware.py,sha256=xaylPReyfRGgvPZXhdw-j0qt8d9qR1YHKa8HD_-y6uA,10048
|
|
30
30
|
managed_deepagents/_managed_thread.py,sha256=P1ogidb2WnGlWpzUyOF6gzhiJOipDEhQ8idlFRiE8hQ,6504
|
|
31
31
|
managed_deepagents/_managed_tools.py,sha256=77ShVQoelQW9M5Ir1r2AiX7ItrrHTX6LzRBVa21m4i0,12997
|
|
32
|
-
managed_deepagents/_memory_instructions.py,sha256=
|
|
32
|
+
managed_deepagents/_memory_instructions.py,sha256=6qLGz_iKjToRaOo4ZwepyJAeEDoOiWXQyh4oa_W5xWw,8374
|
|
33
33
|
managed_deepagents/_routes.py,sha256=TeReerf8TLpUtm95nuHWoT0fK3FVl3v3nhzO-vUpsPA,2369
|
|
34
|
-
managed_deepagents/_run_input.py,sha256=
|
|
34
|
+
managed_deepagents/_run_input.py,sha256=CIJRgjViE96UvS-sCjcwnDm05ydXbpRnGkequqjcadI,18453
|
|
35
35
|
managed_deepagents/_run_local.py,sha256=pKGh_JKUW8RaTFy9EpBor893KCjBV2cCJZzsiBCeaWA,2852
|
|
36
36
|
managed_deepagents/_runtime_schedules.py,sha256=Tjz7rohzv6SDg1jE1W1CugVSZSjiKtNBu22bfDlZPN8,30426
|
|
37
|
-
managed_deepagents/_sandbox_proxy.py,sha256=
|
|
37
|
+
managed_deepagents/_sandbox_proxy.py,sha256=8Zm5zjbrOtnmwi8MxyK02_bilRbDMPRIntuQJXgOJgw,10291
|
|
38
38
|
managed_deepagents/_schedule_auth.py,sha256=4RDPH1QYKLhxn3LYkoebMa974IaaUsyRruQLzgF9w2A,30898
|
|
39
39
|
managed_deepagents/_schedule_channel.py,sha256=r0EWl4OrBJRnwKETHjKdScYIfdi0lrUEGdajX6FGIdQ,1109
|
|
40
40
|
managed_deepagents/_schedule_time.py,sha256=uNyULRjoD0HzPVvV-W772HPb3BYCt0fwEbbT9Ec__Jc,3710
|
|
@@ -46,14 +46,14 @@ managed_deepagents/agent_entry.py,sha256=MnmLGuBMrueqnfHy6CKTsIZeOgaKj7BAlojGO7O
|
|
|
46
46
|
managed_deepagents/browser.py,sha256=dcUhoD8i2ZzxpcsgO7Eb-DUbrd2nHfDpg5MF1pxwqgw,60023
|
|
47
47
|
managed_deepagents/define_browser.py,sha256=FQKYVVRTDqSNGqG4Pzp1H6qngAsL1h0gOhu8bYxJ140,2000
|
|
48
48
|
managed_deepagents/define_deep_agent.py,sha256=QWyYrjZKvMZjdE4223zINJishiDFkhOR6s7knsvEFwI,13174
|
|
49
|
-
managed_deepagents/define_memory.py,sha256=
|
|
49
|
+
managed_deepagents/define_memory.py,sha256=w2_UCODtyimNj5DR2ZBDeGDNds08hrUaZM1UH05AgTM,6793
|
|
50
50
|
managed_deepagents/namespaces.py,sha256=qt41OhCK2mNEDuFwyQ0lkeT5bL0guzv9aRyK3Z-GbVg,4531
|
|
51
51
|
managed_deepagents/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
52
52
|
managed_deepagents/run_context.py,sha256=IayZdcpPrKVss70Hro8qI-EWtL94HZt4JKefzec9qds,3562
|
|
53
|
-
managed_deepagents/runtime.py,sha256=
|
|
53
|
+
managed_deepagents/runtime.py,sha256=Axx6o1rrPBZW99n3thZbVRPqdC5bKbQyL_I_6UZlEUI,139206
|
|
54
54
|
managed_deepagents/sandbox.py,sha256=cS66-vFcARsbHR3fH5jvWd4qF-MAjiGqRe-_Kocsqtg,4693
|
|
55
55
|
managed_deepagents/schedules.py,sha256=z_OlmZ7hW7LdvWLem-BiA131nHwFvUDSW_0-ObzU_G4,6039
|
|
56
|
-
managed_deepagents/_binaries/mda.exe,sha256=
|
|
56
|
+
managed_deepagents/_binaries/mda.exe,sha256=X6ZTaiq8diTyekA8uytbwmz9OCVdraHa70mvgqlAznA,5177344
|
|
57
57
|
managed_deepagents/_channels/__init__.py,sha256=mMgqza7EWRjhJM0lXlFd-W6wBYZrFkpLQ4_30Bpij7k,249
|
|
58
58
|
managed_deepagents/_channels/actor.py,sha256=3d_1-ia6vwVjXkw7PYn5gg6BjnlPwRXW4nW2C5vAO7c,5203
|
|
59
59
|
managed_deepagents/_channels/assistant_text.py,sha256=nf00-KJXNev-e_TkAK_8SBI3J9TiOis1GkGV_zT5048,8472
|
|
@@ -122,13 +122,14 @@ managed_deepagents/_connectors/mcp/__init__.py,sha256=o847QDD82-5CV3Fg6kB0wLde82
|
|
|
122
122
|
managed_deepagents/_connectors/mcp/langsmith_url.py,sha256=RbqcvQPOyTOUOca6zRsROapeGrKUNyQ8dSje5FWMwas,1683
|
|
123
123
|
managed_deepagents/_connectors/mcp/load.py,sha256=2qMCXUhZhtdc0es9GnBZ5kVOcRIkXo2aK8jDJnuQ0oE,35178
|
|
124
124
|
managed_deepagents/_memory/__init__.py,sha256=Z6GljzgF3XojNPGH1RN93TZhgCVhcxvS5IaotZ91dOk,371
|
|
125
|
+
managed_deepagents/_memory/assistant_memory.py,sha256=uiRcUxSt5uO4eeYtFUK5FuXwSp4aave3m2a8p5O-U7E,1809
|
|
125
126
|
managed_deepagents/_memory/async_util.py,sha256=gyN1PqRp94zSC12CZjD_daihtuf4rYTws_G7OIeW86k,1783
|
|
126
127
|
managed_deepagents/_memory/context_io.py,sha256=twvf8xPBP77uipZel9EyUUxQDggD9aI_eYc34QC0SRE,1666
|
|
127
128
|
managed_deepagents/_memory/deps.py,sha256=frtjzejmUYxmmrakUSLq0GdDhEMnY1eTy7mcMA06M30,967
|
|
128
|
-
managed_deepagents/_memory/layers.py,sha256=
|
|
129
|
-
managed_deepagents/_memory/mounts.py,sha256=
|
|
129
|
+
managed_deepagents/_memory/layers.py,sha256=wS1dpHhUFtQ77A0e-udnO-DurZDdhDwCS8EhAyhu-4w,6668
|
|
130
|
+
managed_deepagents/_memory/mounts.py,sha256=Zba-wKiE3fS0AZHj6l4tpjq7d8JWOufSxZTyo5sQX1k,23678
|
|
130
131
|
managed_deepagents/_memory/paths.py,sha256=PUFLoo-mneO4bRI1V4f2AMUmwitCWNvIiXJh9U9HqqA,620
|
|
131
|
-
managed_deepagents/_memory/policy.py,sha256=
|
|
132
|
+
managed_deepagents/_memory/policy.py,sha256=Lj5hBi7TlUBwJPjuv1u0WOQ9ZngSU7Ngt5G51BhXmwA,5205
|
|
132
133
|
managed_deepagents/_memory/selected_skills.py,sha256=4h9H-yNRom7ThK1mtYKozaUh99Nuh0IPSSa2VKpNOPU,19465
|
|
133
134
|
managed_deepagents/_memory/types.py,sha256=f5jZ38wN26ciOsjVPb0_GjHOvfZrF16M9694e4P8KuA,312
|
|
134
135
|
managed_deepagents/_memory/user_memory.py,sha256=FbdO0S2TWI-kit2FntKsFTg58iqpr0vzgf9RovE1HHs,8141
|
|
@@ -140,7 +141,7 @@ managed_deepagents/_telemetry/event.py,sha256=QLv-fEs9-FMGLljnMGAFW4S7FLOX4xRMzu
|
|
|
140
141
|
managed_deepagents/_telemetry/gates.py,sha256=jHsuMdH0i0sPWs6f3CwCxMrDkYndc9PG8KcCA38ong8,596
|
|
141
142
|
managed_deepagents/_telemetry/lifecycle.py,sha256=TDBQbWM2g_N2RJaT3lQaPoSw-mSlPDWBvVQQpPdg8rI,2167
|
|
142
143
|
managed_deepagents/_telemetry/metadata.py,sha256=x41Ro7u5co9GfL_mlC9UEc3ww9iWbVE6ZFTwFsEKQ9Q,5175
|
|
143
|
-
managed_deepagents/_telemetry/run.py,sha256=
|
|
144
|
+
managed_deepagents/_telemetry/run.py,sha256=ZbnAr9YyZWRXT9gybMELkF_YFhfrHwliPIySYIdpy_Q,7878
|
|
144
145
|
managed_deepagents/_telemetry/run_wrapper.py,sha256=cfY1NI9vdJX5a0stIEhi2XQie0eeGn9Ud8cf-Nlf5TA,6584
|
|
145
146
|
managed_deepagents/_telemetry/otel/__init__.py,sha256=9L97Jzj0ER_Dte8d5pqDcQhSDRDDd8pcTTZI0YKzR8M,910
|
|
146
147
|
managed_deepagents/_telemetry/otel/context.py,sha256=fhmmVlBXRhEmXu5dRBNTlnhUH20Ght-_sQsnw8Rwuvc,5473
|
|
@@ -156,9 +157,9 @@ managed_deepagents/identity/__init__.py,sha256=uZUKDHtfBc0n-T2xoJEFMqMplmXwAK7hb
|
|
|
156
157
|
managed_deepagents/identity/claims.py,sha256=prby7r_8Lww3MmoBm8PX6PsSGE3GwSHkr8mVIz_08nU,1180
|
|
157
158
|
managed_deepagents/identity/options.py,sha256=x_yMbXEFR7zXyehEjDHG2qjAlukXjrRBcQLcM6IndLM,2550
|
|
158
159
|
managed_deepagents/identity/supabase.py,sha256=8uobl3WCrQL_ieSXG8KTLf1th7Qjim9liZT50HeaJE0,6026
|
|
159
|
-
managed_deepagents-0.10.4.
|
|
160
|
-
managed_deepagents-0.10.4.
|
|
161
|
-
managed_deepagents-0.10.4.
|
|
162
|
-
managed_deepagents-0.10.4.
|
|
163
|
-
managed_deepagents-0.10.4.
|
|
164
|
-
managed_deepagents-0.10.4.
|
|
160
|
+
managed_deepagents-0.10.4.dev4.dist-info/licenses/LICENSE,sha256=WnPZQQ608ojZUkXl7BW6VbKloIAibZiGm1K6cjeZOL8,1066
|
|
161
|
+
managed_deepagents-0.10.4.dev4.dist-info/METADATA,sha256=pVIcmLAJDyFfzESPbH4d8zYw5cAPoC_HSy0SiQjPexM,95664
|
|
162
|
+
managed_deepagents-0.10.4.dev4.dist-info/WHEEL,sha256=bhMFZwp6VMtrbl2Ck6PlXryKaCggO1NzYn_HcFbBF1I,97
|
|
163
|
+
managed_deepagents-0.10.4.dev4.dist-info/entry_points.txt,sha256=ziZqkKuaDO3qHCjKmBhrx9cm3ok8bZ9xcEDpUTj4unM,53
|
|
164
|
+
managed_deepagents-0.10.4.dev4.dist-info/top_level.txt,sha256=fdBo4O0Hlol_w022tTLB5ftZpamb4yJoQ3MUvjgTGfA,19
|
|
165
|
+
managed_deepagents-0.10.4.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{managed_deepagents-0.10.4.dev2.dist-info → managed_deepagents-0.10.4.dev4.dist-info}/top_level.txt
RENAMED
|
File without changes
|