{"record":{"id":"b07961832ac11109","repo":"langchain-ai/deepagents","slug":"cli-max-retries-must-be-none-or-an-int-got-self","errorCode":null,"errorMessage":"cli_max_retries must be None or an int, got {self.cli_max_retries!r}","messagePattern":"cli_max_retries must be None or an int, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5578,"sourceCode":"        it was the one budget field in dcode without the check -- which is the\n        argument for a single validated budget type rather than a ninth copy of\n        this predicate.\n\n        Raises:\n            TypeError: If `model_retries` or `cli_max_retries` is a `bool`.\n            ValueError: If `model_retries` or `cli_max_retries` is negative.\n        \"\"\"\n        if isinstance(self.model_retries, bool):\n            msg = f\"model_retries must be an int, got {self.model_retries!r}\"\n            raise TypeError(msg)\n        if self.model_retries < 0:\n            msg = f\"model_retries must be >= 0, got {self.model_retries}\"\n            raise ValueError(msg)\n        if isinstance(self.cli_max_retries, bool):\n            msg = (\n                f\"cli_max_retries must be None or an int, got {self.cli_max_retries!r}\"\n            )\n            raise TypeError(msg)\n        if self.cli_max_retries is not None and self.cli_max_retries < 0:\n            msg = f\"cli_max_retries must be >= 0, got {self.cli_max_retries}\"\n            raise ValueError(msg)\n\n    def apply_to_runtime_state(self) -> None:\n        \"\"\"Commit this result's metadata to global `runtime_state`.\"\"\"\n        state = _get_runtime_state()\n        state.model_name = self.model_name\n        state.model_provider = self.provider\n        state.model_context_limit = self.context_limit\n        state.model_unsupported_modalities = self.unsupported_modalities\n\n\ndef _apply_profile_overrides(\n    model: BaseChatModel,\n    overrides: dict[str, Any],\n    model_name: str,\n    *,","sourceCodeStart":5560,"sourceCodeEnd":5596,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5560-L5596","documentation":"`ModelResult.__post_init__` raising TypeError because `cli_max_retries` is a bool instead of None or an int. Same rationale as model_retries: `True` would silently act as a retry budget of 1.","triggerScenarios":"Constructing `ModelResult(...)` with `cli_max_retries=True`/`False`. The CLI flag path enforces `non_negative_int`, so this fires only when the value bypasses argparse (programmatic construction, hand-wired config plumbing).","commonSituations":"Tests or tooling constructing ModelResult directly; a bool leaking from a config parser that accepts true/false.","solutions":["Pass an int or None for `cli_max_retries`, never a bool.","Coerce config-sourced values with a validator that rejects bools before construction.","Use None to mean 'flag not set' rather than False."],"exampleFix":"// before\nModelResult(..., cli_max_retries=False)\n// after\nModelResult(..., cli_max_retries=None)  # or an int like 3","handlingStrategy":"type-guard","validationCode":"def is_cli_max_retries(v: object) -> bool:\n    return v is None or (isinstance(v, int) and not isinstance(v, bool) and v >= 0)\nassert is_cli_max_retries(cli_max_retries)","typeGuard":"def is_optional_int(v: object) -> TypeGuard[int | None]:\n    return v is None or (isinstance(v, int) and not isinstance(v, bool))","tryCatchPattern":"try:\n    result = ModelResult(..., cli_max_retries=v)\nexcept TypeError:\n    result = ModelResult(..., cli_max_retries=None if isinstance(v, bool) else v)","preventionTips":["Use None (not False) for 'flag not set'","Coerce CLI/config values with a bool-rejecting validator before plumbing them into ModelResult","Let argparse's non_negative_int own the flag parsing; don't re-derive the value as a bool"],"tags":["type-error","retry-budget","validation"],"backgroundTag":"bool-not-int","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}