{"record":{"id":"528611c60fd0f979","repo":"langchain-ai/deepagents","slug":"timeout-must-be-positive-got-timeout","errorCode":null,"errorMessage":"timeout must be positive, got {timeout}","messagePattern":"timeout must be positive, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/backends/local_shell.py","lineNumber":183,"sourceCode":"\n            env: Environment variables for shell commands.\n\n                If `None`, starts with an empty environment\n                (unless `inherit_env=True`).\n\n            inherit_env: Whether to inherit the parent process's environment variables.\n\n                When `False` (default), only variables in `env` dict are available.\n\n                When `True`, inherits all `os.environ` variables\n                and applies `env` overrides.\n\n        Raises:\n            ValueError: If timeout is not positive.\n        \"\"\"\n        if timeout <= 0:\n            msg = f\"timeout must be positive, got {timeout}\"\n            raise ValueError(msg)\n\n        # Initialize parent FilesystemBackend\n        super().__init__(\n            root_dir=root_dir,\n            virtual_mode=virtual_mode,\n            max_file_size_mb=10,\n        )\n\n        # Store execution parameters\n        self._default_timeout = timeout\n        self._max_output_bytes = max_output_bytes\n\n        # Build environment based on inherit_env setting\n        if inherit_env:\n            self._env = os.environ.copy()\n            if env is not None:\n                self._env.update(env)\n        else:","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/backends/local_shell.py#L165-L201","documentation":"LocalShellBackend's constructor requires a strictly positive timeout (in seconds) for command execution and raises ValueError otherwise. A non-positive timeout would make every subprocess.run call invalid, so the backend refuses construction.","triggerScenarios":"LocalShellBackend(root_dir=..., timeout=0) or timeout=-1, often from a config value defaulting to 0 (unset) or a computed value like deadline - now that reached zero.","commonSituations":"Config files where timeout is unset and coerces to 0, parsing durations as ints and losing fractions, or an expired deadline being passed through.","solutions":["Pass a positive timeout, e.g. timeout=30","Fix config loading so an unset timeout falls back to a positive default instead of 0","Guard computed deadlines: use max(some_minimum, remaining_time)","Omit the argument to use the class's built-in default if you have no preference"],"exampleFix":"// before\nbackend = LocalShellBackend(root_dir=cfg.root, timeout=cfg.get(\"timeout\", 0))\n// after\nbackend = LocalShellBackend(root_dir=cfg.root, timeout=cfg.get(\"timeout\", 30))","handlingStrategy":"validation","validationCode":"timeout = cfg.get(\"timeout\") or DEFAULT_TIMEOUT\nif timeout <= 0:\n    raise ValueError(f\"configured timeout must be positive, got {timeout}\")\nbackend = LocalShellBackend(root_dir=root, timeout=timeout)","typeGuard":null,"tryCatchPattern":"try:\n    backend = LocalShellBackend(root_dir=root, timeout=cfg_timeout)\nexcept ValueError as exc:\n    if \"timeout must be positive\" in str(exc):\n        backend = LocalShellBackend(root_dir=root)  # fall back to default\n    else:\n        raise","preventionTips":["Give config defaults a positive fallback instead of 0","Validate configured durations at startup, before constructing backends"],"tags":["python","argument-validation","configuration","shell"],"backgroundTag":"invalid-timeout-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}