Restrict deepagents create_deep_agent tools via middleware
@marcdasilva▲ 0 net votes
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.