Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0e9c30a
add --allow-fs-tools to dcode
imnishitha Jul 10, 2026
14d0a58
tests
imnishitha Jul 10, 2026
cd766e4
Merge branch 'main' into nm/dcode-tools-allowlist
imnishitha Jul 10, 2026
3d70ef0
lint fixes
imnishitha Jul 10, 2026
20dd6cc
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 13, 2026
e8049d4
cr
mdrxy Jul 13, 2026
5bf26fe
cr
mdrxy Jul 13, 2026
9b45783
cr
mdrxy Jul 13, 2026
67f8972
cr
mdrxy Jul 13, 2026
02f6eae
Merge remote-tracking branch 'origin/main' into nm/dcode-tools-allowlist
mdrxy Jul 17, 2026
69e33ac
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 21, 2026
ccaab2c
feat(code): support a configurable tools allowlist
mdrxy Jul 21, 2026
c9c5659
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 21, 2026
7adece0
Merge remote-tracking branch 'origin/main' into nm/dcode-tools-allowlist
mdrxy Jul 21, 2026
d54fe15
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 21, 2026
76508ca
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 21, 2026
072483f
nits
mdrxy Jul 21, 2026
52642ba
refactor(code): remove duplicate filesystem tool guidance
mdrxy Jul 21, 2026
3e43e74
fix(code): extend `--allow-fs-tools` restriction to goal-criteria age…
mdrxy Jul 22, 2026
ad90d73
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 22, 2026
fdf6fbc
nits
mdrxy Jul 22, 2026
21b3246
fix(code): preserve SDK filesystem defaults for `all`
mdrxy Jul 22, 2026
af330c1
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 22, 2026
c7011c6
fix(code): hide guidance for disabled filesystem tools
mdrxy Jul 22, 2026
0b96152
Merge branch 'main' into nm/dcode-tools-allowlist
mdrxy Jul 22, 2026
0afe376
fix(code): validate filesystem tool allowlists
mdrxy Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion libs/code/deepagents_code/_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import os
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

from deepagents_code._constants import DEFAULT_AGENT_NAME as DEFAULT_ASSISTANT_ID
from deepagents_code._env_vars import SERVER_ENV_PREFIX

if TYPE_CHECKING:
from deepagents import FsToolName

from deepagents_code.project_utils import ProjectContext


Expand Down Expand Up @@ -258,6 +260,15 @@ class ServerConfig:
`interpreter_ptc="all"` is paired with non-`auto_approve` mode.
"""

allow_fs_tools: Literal["all"] | list[FsToolName] | None = None
"""Allowlist for `FilesystemMiddleware`'s `tools` param, from
`--allow-fs-tools`.

`None` leaves the SDK default (all filesystem tools). A string is
`"all"`; a list is an explicit allowlist of filesystem tool names and
must include `"read_file"`.
"""

rubric_model: str | None = None
"""Grader model spec for `RubricMiddleware` (e.g. `'anthropic:...'`).

Expand Down Expand Up @@ -362,6 +373,11 @@ def to_env(self) -> dict[str, str | None]:
"INTERPRETER_PTC_ACKNOWLEDGE_UNSAFE": str(
self.interpreter_ptc_acknowledge_unsafe
).lower(),
"ALLOW_FS_TOOLS": (
json.dumps(self.allow_fs_tools)
if self.allow_fs_tools is not None
else None
),
"RUBRIC_MODEL": self.rubric_model,
"RUBRIC_MAX_ITERATIONS": (
str(self.rubric_max_iterations)
Expand Down Expand Up @@ -416,6 +432,7 @@ def from_env(cls) -> ServerConfig:
interpreter_ptc_acknowledge_unsafe=_read_env_bool(
"INTERPRETER_PTC_ACKNOWLEDGE_UNSAFE"
),
allow_fs_tools=_read_env_json("ALLOW_FS_TOOLS"),
rubric_model=_read_env_str("RUBRIC_MODEL") or None,
rubric_max_iterations=_read_env_int("RUBRIC_MAX_ITERATIONS", default=None),
sandbox_type=_read_env_str("SANDBOX_TYPE"),
Expand Down Expand Up @@ -453,6 +470,7 @@ def from_cli_args(
enable_interpreter: bool | None = None,
interpreter_ptc: str | list[str] | None = None,
interpreter_ptc_acknowledge_unsafe: bool = False,
allow_fs_tools: Literal["all"] | list[FsToolName] | None = None,
rubric_model: str | None = None,
rubric_max_iterations: int | None = None,
mcp_config_path: str | None,
Expand Down Expand Up @@ -488,6 +506,9 @@ def from_cli_args(
interpreter_ptc: Override for `settings.interpreter_ptc`.
interpreter_ptc_acknowledge_unsafe: Mirror of
`settings.interpreter_ptc_acknowledge_unsafe`.
allow_fs_tools: Allowlist for `FilesystemMiddleware`'s `tools`
param to forward to the server subprocess. `None` leaves the
SDK default (all tools).
rubric_model: Grader model spec; `None` reuses the main model.
rubric_max_iterations: Explicit grader iterations per rubric attempt;
`None` uses the SDK default.
Expand Down Expand Up @@ -518,6 +539,7 @@ def from_cli_args(
enable_interpreter=resolved_enable_interpreter,
interpreter_ptc=interpreter_ptc,
interpreter_ptc_acknowledge_unsafe=interpreter_ptc_acknowledge_unsafe,
allow_fs_tools=allow_fs_tools,
rubric_model=rubric_model,
rubric_max_iterations=rubric_max_iterations,
sandbox_type=sandbox_type,
Expand Down
33 changes: 31 additions & 2 deletions libs/code/deepagents_code/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import tomllib
import warnings
from pathlib import Path, PurePosixPath
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, Literal, cast

from deepagents import create_deep_agent
from deepagents import FsToolName, create_deep_agent
from deepagents.backends import CompositeBackend, LocalShellBackend
from deepagents.backends.filesystem import FilesystemBackend
from deepagents.middleware import (
Expand Down Expand Up @@ -1316,6 +1316,7 @@ def create_cli_agent(
auto_approve: bool = False,
interrupt_shell_only: bool = False,
shell_allow_list: list[str] | None = None,
fs_tools: list[FsToolName] | Literal["all"] | None = None,
enable_ask_user: bool = True,
enable_memory: bool = True,
enable_skills: bool = True,
Expand Down Expand Up @@ -1371,6 +1372,14 @@ def create_cli_agent(
the CLI process. When provided (and `interrupt_shell_only` is
`True`), used directly instead of reading `settings.shell_allow_list`
(which may not be set in the server subprocess environment).
fs_tools: Allowlist of filesystem tools to expose to the agent, from
`--allow-fs-tools`. `None` (default) leaves `FilesystemMiddleware`
at its SDK default (all tools). `"all"` or an explicit list
(which must include `"read_file"`) installs a `FilesystemMiddleware`
restricted to those tool names, replacing the SDK's default
instance for the main agent and every synchronous subagent
(including `general-purpose`), so delegating via `task` cannot
bypass the restriction. Async subagents are unaffected.
enable_ask_user: Enable `AskUserMiddleware` so the agent can ask
clarifying questions.

Expand Down Expand Up @@ -1797,6 +1806,26 @@ def _subagent_cli_middleware(*, has_explicit_model: bool) -> list[AgentMiddlewar
routes={},
)

if fs_tools is not None:
# Overrides the SDK's default `FilesystemMiddleware` (matched by
# `.name` in `create_deep_agent`'s custom-middleware merge) for the
# main agent.
agent_middleware.append(
FilesystemMiddleware(backend=composite_backend, tools=fs_tools)
)
# Sync subagents don't inherit the main agent's `middleware=` (the SDK's
# inheritance path is bypassed when an explicit `general-purpose` subagent is
# provided). Inject the restriction into each subagent so `task` can't bypass
# `--allow-fs-tools`.
for subagent in cast("list[SubAgent]", custom_subagents):
subagent["middleware"] = cast(
"list[AgentMiddleware]",
[
*subagent.get("middleware", []),
FilesystemMiddleware(backend=composite_backend, tools=fs_tools),
],
)

from deepagents.middleware.summarization import create_summarization_tool_middleware

agent_middleware.append(
Expand Down
12 changes: 11 additions & 1 deletion libs/code/deepagents_code/client/launch/server_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
from contextlib import asynccontextmanager
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

if TYPE_CHECKING:
from collections.abc import AsyncIterator

from deepagents import FsToolName

from deepagents_code.client.launch.server import ServerProcess
from deepagents_code.client.remote_client import RemoteAgent
from deepagents_code.mcp_tools import MCPSessionManager
Expand Down Expand Up @@ -304,6 +306,7 @@ async def start_server_and_get_agent(
enable_interpreter: bool | None = None,
interpreter_ptc: str | list[str] | None = None,
interpreter_ptc_acknowledge_unsafe: bool = False,
allow_fs_tools: Literal["all"] | list[FsToolName] | None = None,
rubric_model: str | None = None,
rubric_max_iterations: int | None = None,
mcp_config_path: str | None = None,
Expand Down Expand Up @@ -333,6 +336,8 @@ async def start_server_and_get_agent(
interpreter_ptc: Override for `settings.interpreter_ptc` (PTC allowlist).
interpreter_ptc_acknowledge_unsafe: Explicit acknowledgement for
`interpreter_ptc="all"` outside of `auto_approve`.
allow_fs_tools: Allowlist for `FilesystemMiddleware`'s `tools` param.
`None` leaves the SDK default (all tools).
rubric_model: Grader model spec; `None` reuses the main model.
rubric_max_iterations: Explicit grader iterations per rubric attempt;
`None` uses the SDK default.
Expand Down Expand Up @@ -382,6 +387,7 @@ async def start_server_and_get_agent(
enable_interpreter=enable_interpreter,
interpreter_ptc=interpreter_ptc,
interpreter_ptc_acknowledge_unsafe=interpreter_ptc_acknowledge_unsafe,
allow_fs_tools=allow_fs_tools,
rubric_model=rubric_model,
rubric_max_iterations=rubric_max_iterations,
mcp_config_path=mcp_config_path,
Expand Down Expand Up @@ -454,6 +460,7 @@ async def server_session(
enable_interpreter: bool | None = None,
interpreter_ptc: str | list[str] | None = None,
interpreter_ptc_acknowledge_unsafe: bool = False,
allow_fs_tools: Literal["all"] | list[FsToolName] | None = None,
rubric_model: str | None = None,
rubric_max_iterations: int | None = None,
mcp_config_path: str | None = None,
Expand Down Expand Up @@ -486,6 +493,8 @@ async def server_session(
interpreter_ptc: Override for `settings.interpreter_ptc` (PTC allowlist).
interpreter_ptc_acknowledge_unsafe: Explicit acknowledgement for
`interpreter_ptc="all"` outside of `auto_approve`.
allow_fs_tools: Allowlist for `FilesystemMiddleware`'s `tools` param.
`None` leaves the SDK default (all tools).
rubric_model: Grader model spec; `None` reuses the main model.
rubric_max_iterations: Explicit grader iterations per rubric attempt;
`None` uses the SDK default.
Expand Down Expand Up @@ -520,6 +529,7 @@ async def server_session(
enable_interpreter=enable_interpreter,
interpreter_ptc=interpreter_ptc,
interpreter_ptc_acknowledge_unsafe=interpreter_ptc_acknowledge_unsafe,
allow_fs_tools=allow_fs_tools,
rubric_model=rubric_model,
rubric_max_iterations=rubric_max_iterations,
mcp_config_path=mcp_config_path,
Expand Down
7 changes: 6 additions & 1 deletion libs/code/deepagents_code/client/non_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import threading
import time
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, Literal, cast

from langchain.agents.middleware.human_in_the_loop import ActionRequest, HITLRequest
from langchain_core.messages import AIMessage, ToolMessage
Expand Down Expand Up @@ -83,6 +83,7 @@
if TYPE_CHECKING:
from asyncio.subprocess import Process

from deepagents import FsToolName
from langchain_core.runnables import RunnableConfig

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1342,6 +1343,7 @@ async def run_non_interactive(
enable_interpreter: bool | None = None,
interpreter_ptc: str | list[str] | None = None,
interpreter_ptc_acknowledge_unsafe: bool = False,
allow_fs_tools: Literal["all"] | list[FsToolName] | None = None,
max_turns: int | None = None,
rubric: str | None = None,
rubric_model: str | None = None,
Expand Down Expand Up @@ -1407,6 +1409,8 @@ async def run_non_interactive(
allowlist for `js_eval`).
interpreter_ptc_acknowledge_unsafe: Explicit acknowledgement for
`interpreter_ptc="all"` outside of `auto_approve`.
allow_fs_tools: Allowlist for `FilesystemMiddleware`'s `tools` param,
from `--allow-fs-tools`. `None` leaves the SDK default (all tools).
max_turns: Optional cap on total agentic turns. When `None`, the
internal safety default applies.
rubric: Acceptance criteria for `RubricMiddleware`. When provided, the
Expand Down Expand Up @@ -1607,6 +1611,7 @@ async def run_non_interactive(
enable_interpreter=enable_interpreter,
interpreter_ptc=interpreter_ptc,
interpreter_ptc_acknowledge_unsafe=interpreter_ptc_acknowledge_unsafe,
allow_fs_tools=allow_fs_tools,
rubric_model=rubric_model,
rubric_max_iterations=rubric_max_iterations,
mcp_config_path=mcp_config_path,
Expand Down
Loading
Loading