{"record":{"id":"84741952c4687412","repo":"langchain-ai/deepagents","slug":"max-execute-timeout-must-be-positive-got-max-exe","errorCode":null,"errorMessage":"max_execute_timeout must be positive, got {max_execute_timeout}","messagePattern":"max_execute_timeout must be positive, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/filesystem.py","lineNumber":1700,"sourceCode":"                `\"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,\n        )\n        if _permissions and supports_execution(self.backend) and not _all_paths_scoped_to_routes(_permissions, self.backend):\n            msg = (","sourceCodeStart":1682,"sourceCodeEnd":1718,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/filesystem.py#L1682-L1718","documentation":"FilesystemMiddleware validates that max_execute_timeout is a positive number; a zero or negative value is rejected in __init__ with this ValueError, since command execution must always have a meaningful timeout.","triggerScenarios":"FilesystemMiddleware(max_execute_timeout=0) or a negative value; computing the timeout from config/env where the value is missing (0) or mis-scaled (e.g. -1 as a sentinel).","commonSituations":"Env var like EXEC_TIMEOUT unset and int('') fallback to 0; config accidentally treating -1 as 'unlimited'; unit confusion (seconds vs ms yielding 0).","solutions":["Pass a positive timeout (e.g. max_execute_timeout=60)","Fix the env/config parsing that produced the non-positive value","Omit the parameter to use the default timeout"],"exampleFix":"// before\nFilesystemMiddleware(max_execute_timeout=int(os.environ.get(\"EXEC_TIMEOUT\", 0)))\n// after\nFilesystemMiddleware(max_execute_timeout=int(os.environ.get(\"EXEC_TIMEOUT\", 300)))","handlingStrategy":"validation","validationCode":"timeout = int(os.environ.get(\"EXEC_TIMEOUT\", 300))\nif timeout <= 0:\n    raise ValueError(f\"EXEC_TIMEOUT must be positive, got {timeout}\")","typeGuard":null,"tryCatchPattern":"try:\n    mw = FilesystemMiddleware(max_execute_timeout=timeout)\nexcept ValueError as e:\n    logger.error(\"invalid execute timeout: %s\", e)\n    timeout = 300\n    mw = FilesystemMiddleware(max_execute_timeout=timeout)","preventionTips":["Never use 0 or -1 as 'unlimited' sentinels; use None/default instead","Validate env-derived numeric config before constructing middleware","Add tests for config edge values (0, negative, missing)"],"tags":["python","filesystem","configuration","validation"],"backgroundTag":"invalid-timeout-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}