{"record":{"id":"d4663f4eafcfc3c2","repo":"langchain-ai/deepagents","slug":"max-retries-must-be-at-least-1","errorCode":null,"errorMessage":"max_retries must be at least 1","messagePattern":"max_retries must be at least 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/runtime.py","lineNumber":257,"sourceCode":"        middleware: Sequence[AgentMiddleware[Any, Any, Any]] = (),\n        interrupt_on: Mapping[str, bool | InterruptOnConfig] | None = None,\n        memory: Sequence[str] | None = None,\n        checkpointer: Checkpointer | None = None,\n        include_web_tools: bool = True,\n        recursion_limit: int = DEFAULT_RECURSION_LIMIT,\n        max_retries: int = DEFAULT_MAX_RETRIES,\n        max_continuations: int = DEFAULT_MAX_CONTINUATIONS,\n        env: Mapping[str, str] | None = None,\n    ) -> None:\n        \"\"\"Initialize without constructing the graph.\"\"\"\n        values = os.environ if env is None else env\n        resolved_recursion_limit = _recursion_limit_from_env(values, recursion_limit)\n        if resolved_recursion_limit <= 0:\n            msg = \"recursion_limit must be positive\"\n            raise ValueError(msg)\n        if max_retries < 1:\n            msg = \"max_retries must be at least 1\"\n            raise ValueError(msg)\n        if max_continuations < 0:\n            msg = \"max_continuations cannot be negative\"\n            raise ValueError(msg)\n\n        self.model = model\n        self.tools = tuple(tools)\n        self.system_prompt = system_prompt\n        self.subagents = tuple(subagents) if subagents is not None else None\n        self._has_async_subagents = _has_async_subagents(self.subagents)\n        self.assistant_dir = assistant_dir\n        self.cron_store = cron_store\n        self.env = dict(os.environ if env is None else env)\n        self.backend = backend if backend is not None else _default_backend(self.env)\n        self.skills = tuple(skills) if skills is not None else None\n        self.middleware = tuple(middleware)\n        self.interrupt_on = interrupt_on_with_env_overlay(interrupt_on, self.env)\n        self.memory = tuple(memory) if memory is not None else None\n        self.checkpointer = checkpointer if checkpointer is not None else InMemorySaver()","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/runtime.py#L239-L275","documentation":"DeepAgentRuntime.__init__ requires max_retries to be at least 1 and raises this ValueError otherwise. The retry loop in _invoke_payload_with_retries is written assuming at least one attempt, so 0 or negative values are rejected up front.","triggerScenarios":"Constructing DeepAgentRuntime with max_retries=0 or a negative number.","commonSituations":"Config that uses 0 to mean 'no retries' (this library means 'at least one attempt'); a computed retry count like `max(0, attempts - 1)` fed straight into the constructor.","solutions":["Pass max_retries >= 1 to DeepAgentRuntime","If you want effectively no retries, use max_retries=1 (single attempt)","Clamp computed values before construction: `max_retries=max(1, computed)`"],"exampleFix":"// before\nruntime = DeepAgentRuntime(..., max_retries=0)\n// after\nruntime = DeepAgentRuntime(..., max_retries=1)  # 1 = single attempt, no retries","handlingStrategy":"validation","validationCode":"def sanitize_retries(n: int) -> int:\n    return max(1, int(n))\n\nruntime = DeepAgentRuntime(..., max_retries=sanitize_retries(config.retries))","typeGuard":"def valid_retries(v: object) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 1","tryCatchPattern":null,"preventionTips":["Remember 1 means 'one attempt, no retries' in this API","Clamp computed retry counts with max(1, n) at the config boundary","Document retry semantics in your config schema so 0 is never emitted"],"tags":["configuration","validation","retry"],"backgroundTag":"invalid-config-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}