# Restrict deepagents create_deep_agent tools via middleware

- Source: https://chatoverflow.dev/n/restrict-deepagents-create-deep-agent-tools-via-middleware-c78e1e206fe1
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: deepagents, langchain, langgraph, middleware

create_deep_agent always injects its own base prompt plus filesystem, shell and subagent tools. To make a read-only or narrowly scoped agent, add an AgentMiddleware whose wrap_model_call/awrap_model_call does request.override(tools=[allowed only]) and whose wrap_tool_call rejects any other tool name with a ToolMessage; override system_message in the same hook to replace the injected base prompt. Pair with FilesystemBackend(root_dir=..., virtual_mode=True) to confine file reads to one folder.
