microsoft/autogen · error · ValueError
Timeout must be greater than or equal to 1.
Error message
Timeout must be greater than or equal to 1.
What it means
Constructor validation in JupyterCodeExecutor: the timeout (seconds per cell execution, default 60) must be >= 1. Zero or negative values raise ValueError immediately; None is not accepted here.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/jupyter/_jupyter_code_executor.py:146
timeout (int): The timeout for code execution, by default 60.
output_dir (Path): The directory to save output files, by default a temporary directory.
.. note::
Using the current directory (".") as output directory is deprecated. Using it will raise a deprecation warning.
"""
component_config_schema = JupyterCodeExecutorConfig
component_provider_override = "autogen_ext.code_executors.jupyter.JupyterCodeExecutor"
def __init__(
self,
kernel_name: str = "python3",
timeout: int = 60,
output_dir: Optional[Union[Path, str]] = None,
):
if timeout < 1:
raise ValueError("Timeout must be greater than or equal to 1.")
self._output_dir: Path = Path(tempfile.mkdtemp()) if output_dir is None else Path(output_dir)
self._output_dir.mkdir(exist_ok=True, parents=True)
self._temp_dir: Optional[tempfile.TemporaryDirectory[str]] = None
self._temp_dir_path: Optional[Path] = None
self._started = False
self._kernel_name = kernel_name
self._timeout = timeout
self._client: Optional[NotebookClient] = None
self.kernel_context: Optional[AbstractAsyncContextManager[None]] = None
async def execute_code_blocks(
self, code_blocks: list[CodeBlock], cancellation_token: CancellationToken
) -> JupyterCodeResult:View on GitHub (pinned to 027ecf0a37)
Solutions
- Pass timeout >= 1 seconds (default 60 is usually fine).
- Sanitize external config: timeout = max(1, int(raw_value)) before constructing.
- Confirm you are not passing None where an int is required.
Example fix
# before executor = JupyterCodeExecutor(timeout=0) # after executor = JupyterCodeExecutor(timeout=60)
Defensive patterns
Strategy: validation
Validate before calling
timeout = int(os.getenv("EXEC_TIMEOUT", "60")) or 60
timeout = max(1, timeout) Type guard
def is_valid_timeout(t: object) -> bool:
return isinstance(t, int) and not isinstance(t, bool) and t >= 1 Try / catch
try:
JupyterCodeExecutor(timeout=t)
except ValueError as e:
if "Timeout" in str(e):
executor = JupyterCodeExecutor(timeout=max(1, int(t)))
else:
raise Prevention
- Use a single config helper that clamps timeouts to >= 1.
- Treat missing timeout config as the default 60, never 0.
When it happens
Trigger: JupyterCodeExecutor(timeout=0) or a negative number, typically from unparsed config values, env vars defaulting to 0, or arithmetic that computes a non-positive timeout.
Common situations: int(os.getenv('TIMEOUT', 0)) when the var is unset, configs migrated from millisecond semantics, tests passing timeout=0 as a placeholder, computed timeouts that underflow to 0.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timeout must be greater than or equal to 1.
- jupyter_server must be a JupyterConnectable or JupyterConnec
- Unsupported config type {config.GetType()}
- Messages should not be provided in options
- The agent name must be a valid Python identifier.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/12f65a7360282e69.
Report an issue: GitHub.