{"record":{"id":"e61bd8d938549f87","repo":"langchain-ai/deepagents","slug":"read-file-must-be-included-in-tools-it-is-require","errorCode":null,"errorMessage":"read_file must be included in tools; it is required by FilesystemMiddleware","messagePattern":"read_file must be included in tools; it is required by FilesystemMiddleware","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/filesystem.py","lineNumber":1697,"sourceCode":"            tools: Allowlist of tool names to expose to the model.\n                ``\"all\"` indicates all tools. If unset, defaults to `\"all\"`.\n                Pass a list containing any of `\"ls\"`, `\"read_file\"`,\n                `\"write_file\"`, `\"edit_file\"`, `\"delete\"`, `\"glob\"`,\n                `\"grep\"`, `\"execute\"` to restrict the model to only those\n                tools; all others are hidden. `read_file` must be included\n                in any list. Backend capability checks for `execute` and\n                `delete` still apply; listing them when the backend does not\n                support them is a no-op.\n            _permissions: Optional filesystem permission rules enforced directly\n                by this middleware's tool implementations.\n\n                Marked private for now because this is an internal\n                implementation detail and may move to the backend layer in a\n                future change.\n        \"\"\"\n        if isinstance(tools, list) and \"read_file\" not in tools:\n            msg = \"read_file must be included in tools; it is required by FilesystemMiddleware\"\n            raise ValueError(msg)\n        if max_execute_timeout <= 0:\n            msg = f\"max_execute_timeout must be positive, got {max_execute_timeout}\"\n            raise ValueError(msg)\n        if grep_max_count is not None and grep_max_count <= 0:\n            msg = f\"grep_max_count must be positive or None, got {grep_max_count}\"\n            raise ValueError(msg)\n        # Use provided backend or default to StateBackend instance\n        self.backend = backend if backend is not None else StateBackend()\n        if callable(self.backend) and not isinstance(self.backend, BackendProtocol):\n            msg = (\n                \"backend must be an initialized backend instance. Backend factories \"\n                \"were removed in deepagents 0.7; pass StateBackend(), \"\n                \"CompositeBackend(...), or another BackendProtocol instance instead.\"\n            )\n            raise TypeError(msg)\n        self.state_schema = cast(\n            \"type[FilesystemState]\",\n            FilesystemState if _uses_state_backend(self.backend) else AgentState,","sourceCodeStart":1679,"sourceCodeEnd":1715,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/filesystem.py#L1679-L1715","documentation":"FilesystemMiddleware.__init__ requires 'read_file' in the tools list when tools is given as a list, because other filesystem features depend on read_file being available. Constructing the middleware with a tools list that omits it raises this ValueError.","triggerScenarios":"FilesystemMiddleware(tools=[\"write_file\", \"ls\", ...]) with \"read_file\" missing; programmatically filtering tools and dropping read_file.","commonSituations":"Slimming the toolset for cost/safety and unknowingly removing the required baseline tool; passing tools as a list (not None/ full set) after customization.","solutions":["Add \"read_file\" to the tools list","Pass tools=None (or the default set) to get the standard toolset","Rework your tool-filtering logic to treat read_file as mandatory"],"exampleFix":"// before\nFilesystemMiddleware(tools=[\"write_file\", \"edit_file\"])\n// after\nFilesystemMiddleware(tools=[\"read_file\", \"write_file\", \"edit_file\"])","handlingStrategy":"validation","validationCode":"REQUIRED_TOOLS = {\"read_file\"}\ndef validate_tools(tools: list[str] | None) -> list[str] | None:\n    if tools is not None and not REQUIRED_TOOLS.issubset(tools):\n        raise ValueError(f\"tools must include {REQUIRED_TOOLS}\")\n    return tools","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat read_file as a mandatory baseline when filtering tools","Add a startup assertion on the final toolset","Prefer removing optional tools (execute, grep) rather than read_file"],"tags":["python","filesystem","configuration","validation"],"backgroundTag":"required-tool-missing","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}