{"record":{"id":"7fc9bf38fb0cd29e","repo":"langchain-ai/deepagents","slug":"max-continuations-cannot-be-negative","errorCode":null,"errorMessage":"max_continuations cannot be negative","messagePattern":"max_continuations cannot be negative","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/talon/deepagents_talon/runtime.py","lineNumber":260,"sourceCode":"        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()\n        self.include_web_tools = include_web_tools\n        self.recursion_limit = resolved_recursion_limit\n        self.max_retries = max_retries","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/talon/deepagents_talon/runtime.py#L242-L278","documentation":"DeepAgentRuntime.__init__ raises this ValueError when max_continuations is negative. Continuation limits control how many times the agent may resume after interrupts; a negative count is meaningless and rejected at construction time.","triggerScenarios":"Constructing DeepAgentRuntime with max_continuations < 0 (e.g. -1 used as a sentinel for 'unlimited').","commonSituations":"Using -1 as an 'unlimited' sentinel as is common in other libraries; arithmetic on counters that underflows below zero before constructing the runtime.","solutions":["Pass max_continuations >= 0; use 0 to disable continuations, or a large positive number for effectively unlimited","Replace any -1 sentinel with 0 or None/omit the argument per the API default","Clamp: `max_continuations=max(0, computed)`"],"exampleFix":"// before\nruntime = DeepAgentRuntime(..., max_continuations=-1)  # meant unlimited\n// after\nruntime = DeepAgentRuntime(..., max_continuations=100)  # or omit to use the default","handlingStrategy":"validation","validationCode":"def sanitize_continuations(n: int) -> int:\n    return max(0, int(n))  # -1 sentinels become 0 (disabled)\n\nruntime = DeepAgentRuntime(..., max_continuations=sanitize_continuations(config.continuations))","typeGuard":"def non_negative_int(v: object) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":null,"preventionTips":["Do not use -1 as an 'unlimited' sentinel for this API; use 0 to disable or a large positive bound","Clamp values at the config boundary before constructing the runtime"],"tags":["configuration","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}