{"record":{"id":"da6229997452fb16","repo":"langchain-ai/deepagents","slug":"cli-max-retries-must-be-none-or-a-non-negative-int","errorCode":null,"errorMessage":"cli_max_retries must be None or a non-negative integer","messagePattern":"cli_max_retries must be None or a non-negative integer","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/_server_config.py","lineNumber":506,"sourceCode":"        # rather than deferring to `FilesystemMiddleware`, which would only\n        # surface the violation a process boundary away. `_parse_allow_fs_tools_flag`\n        # still enforces the same rule at the CLI for a friendlier error.\n        if self.allow_fs_tools is not None:\n            if len(self.allow_fs_tools) == 0:\n                msg = \"allow_fs_tools must be None or a non-empty list\"\n                raise ValueError(msg)\n            if \"read_file\" not in self.allow_fs_tools:\n                msg = \"allow_fs_tools must include 'read_file'\"\n                raise ValueError(msg)\n        if isinstance(self.rubric_max_iterations, bool):\n            msg = \"rubric_max_iterations must be None or a positive integer\"\n            raise TypeError(msg)\n        if self.rubric_max_iterations is not None and self.rubric_max_iterations <= 0:\n            msg = \"rubric_max_iterations must be None or a positive integer\"\n            raise ValueError(msg)\n        if isinstance(self.cli_max_retries, bool):\n            msg = \"cli_max_retries must be None or a non-negative integer\"\n            raise TypeError(msg)\n        if self.cli_max_retries is not None and self.cli_max_retries < 0:\n            msg = \"cli_max_retries must be None or a non-negative integer\"\n            raise ValueError(msg)\n        if isinstance(self.recursion_limit, bool):\n            msg = \"recursion_limit must be None or a positive integer\"\n            raise TypeError(msg)\n        if self.recursion_limit is not None and self.recursion_limit <= 0:\n            msg = \"recursion_limit must be None or a positive integer\"\n            raise ValueError(msg)\n\n    # ------------------------------------------------------------------\n    # Serialization\n    # ------------------------------------------------------------------\n\n    def to_env(self) -> dict[str, str | None]:\n        \"\"\"Serialize this config to a `DEEPAGENTS_CODE_SERVER_*` env-var mapping.\n\n        `None` values signal that the variable should be *cleared* from the","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/_server_config.py#L488-L524","documentation":"ServerConfig validates cli_max_retries: it must be None (library default) or a non-negative integer. This ValueError is raised when a value less than 0 is supplied; True/False raise a TypeError one line earlier. Negative retry counts are meaningless, so the constructor rejects them eagerly.","triggerScenarios":"ServerConfig(cli_max_retries=-1) or any negative int. The same message appears at two raise sites (lines 506 and 509, errors 48 and 49) covering the non-negative check.","commonSituations":"Computing retries as base - consumed and going negative; importing a config from another tool where -1 means 'infinite retries' (the opposite convention); misconfiguring an env var like CLI_MAX_RETRIES=-1.","solutions":["Set cli_max_retries to 0 or a positive integer","Set cli_max_retries=None to use the library's default retry behavior","If -1 was meant as 'unlimited', check the docs for how this library expresses unlimited retries and use that value instead"],"exampleFix":"// before\nconfig = ServerConfig(cli_max_retries=-1)  # meant 'unlimited'\n// after\nconfig = ServerConfig(cli_max_retries=None)","handlingStrategy":"validation","validationCode":"def validate_cli_max_retries(v):\n    if isinstance(v, bool):\n        raise TypeError(\"cli_max_retries must be None or a non-negative integer\")\n    if v is not None and v < 0:\n        raise ValueError(\"cli_max_retries must be None or a non-negative integer\")","typeGuard":"def is_valid_cli_max_retries(v) -> bool:\n    return v is None or (isinstance(v, int) and not isinstance(v, bool) and v >= 0)","tryCatchPattern":"try:\n    config = ServerConfig(cli_max_retries=value)\nexcept (TypeError, ValueError) as e:\n    if \"cli_max_retries\" in str(e):\n        config = ServerConfig(cli_max_retries=None)  # library default\n    else:\n        raise","preventionTips":["Don't use -1 as an 'unlimited' sentinel — this field uses None for defaults","Clamp with max(0, v) when computing retries from a budget","Validate CLI/env-provided retry counts before passing them into ServerConfig"],"tags":["config-validation","valueerror","integer-range"],"backgroundTag":"invalid-config-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}