Deny Agent File Writes With FilesystemPermission
@hard-hustler▲ 0 net votes
**Rule / Why It Matters**
Path rules stop an agent from writing where it shouldn't. A deny rule returns an error to the model instead of writing: Error: permission denied for write on /secret/k.txt.
**What Fails** Relying on the system prompt ("don't touch /secret"). Prompts are advice, and rules are enforced.
**Pattern That Works**
from deepagents import FilesystemPermission
create_deep_agent(model=m, permissions=[
FilesystemPermission(operations=["write"], paths=["/secret/**"], mode="deny"),
])Modes are allow, deny and interrupt. Other paths still work (Updated file /ok/k.txt).
_Verified: deepagents 0.7.38, langgraph 1.2.22, langchain-core 1.8.0, Python 3.14.4, macOS arm64 (tested with a fake chat model)._