{"record":{"id":"98ba7806fef786d8","repo":"langchain-ai/deepagents","slug":"model-retries-must-be-an-int-got-self-model-retr","errorCode":null,"errorMessage":"model_retries must be an int, got {self.model_retries!r}","messagePattern":"model_retries must be an int, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/config.py","lineNumber":5570,"sourceCode":"        the retry resolver itself, so a bad value here signals a caller\n        constructing `ModelResult` by hand with a budget the retry middleware\n        could not honor. `bool` is rejected for the same reason\n        `_model_max_retries` and `CodeModelRetryMiddleware.__init__` reject it:\n        `True` would silently read as a budget of one.\n\n        `cli_max_retries` gets the same gate. It is the field that carries the\n        explicit flag onward to a re-resolution for a different provider, and\n        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","sourceCodeStart":5552,"sourceCodeEnd":5588,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L5552-L5588","documentation":"`ModelResult.__post_init__` validation raising TypeError because `model_retries` is a bool. Bools are rejected because `True` would silently read as a retry budget of 1 (`bool` is an `int` subclass), hiding a caller bug.","triggerScenarios":"Constructing `ModelResult(...)` by hand with `model_retries=True` or `model_retries=False` instead of an integer. Normal config paths coerce via `non_negative_int`/`_coerce_max_retries`, so this only fires on direct construction.","commonSituations":"Programmatic construction of ModelResult in tests or custom tooling, config values parsed from TOML/YAML as booleans passed through uncoerced.","solutions":["Pass an integer (e.g. `model_retries=3`), not True/False.","If the value comes from config, coerce it with an int converter that rejects bools before constructing ModelResult.","Use `0` to explicitly disable retries instead of `False`."],"exampleFix":"// before\nModelResult(model=m, model_name=\"claude-sonnet-4-5\", provider=\"anthropic\", model_retries=True)\n// after\nModelResult(model=m, model_name=\"claude-sonnet-4-5\", provider=\"anthropic\", model_retries=1)","handlingStrategy":"type-guard","validationCode":"def is_retry_budget(v: object) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0\nassert is_retry_budget(model_retries)","typeGuard":"def is_int_not_bool(v: object) -> TypeGuard[int]:\n    return isinstance(v, int) and not isinstance(v, bool)","tryCatchPattern":"try:\n    result = ModelResult(..., model_retries=retries)\nexcept TypeError:\n    retries = int(retries) if not isinstance(retries, bool) else DEFAULT_MODEL_RETRIES\n    result = ModelResult(..., model_retries=retries)","preventionTips":["Never pass True/False where a retry count is expected","Use 0 to disable retries explicitly","Coerce config values with a bool-rejecting int validator before constructing ModelResult","Prefer constructing ModelResult via create_model(), which enforces the config coercions"],"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"}