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 DockerJupyterCodeExecutor: the per-execution timeout (seconds, default 60) must be at least 1. Passing 0 or a negative number is rejected immediately with ValueError before any Docker/Jupyter work begins.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/docker_jupyter/_docker_jupyter.py:166

                    print(response.chat_message)


        asyncio.run(main())

    """

    component_config_schema = DockerJupyterCodeExecutorConfig
    component_provider_override = "autogen_ext.code_executors.docker_jupyter.DockerJupyterCodeExecutor"

    def __init__(
        self,
        jupyter_server: Union[JupyterConnectable, JupyterConnectionInfo],
        kernel_name: str = "python3",
        timeout: int = 60,
        output_dir: Path | None = None,
    ):
        if timeout < 1:
            raise ValueError("Timeout must be greater than or equal to 1.")

        if isinstance(jupyter_server, JupyterConnectable):
            self._connection_info = jupyter_server.connection_info
        elif isinstance(jupyter_server, JupyterConnectionInfo):
            self._connection_info = jupyter_server
        else:
            raise ValueError("jupyter_server must be a JupyterConnectable or JupyterConnectionInfo.")

        self._output_dir = output_dir or getattr(jupyter_server, "_bind_dir", None)
        if not self._output_dir:
            with tempfile.TemporaryDirectory() as temp_dir:
                self._output_dir = Path(temp_dir)
                self._output_dir.mkdir(exist_ok=True)

        self._jupyter_client = JupyterClient(self._connection_info)

        self._kernel_name = kernel_name
        self._timeout = timeout

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Pass timeout >= 1 (seconds), e.g. the default 60.
  2. If timeout comes from configuration, coerce/validate it before construction (timeout = max(1, int(timeout))).
  3. Check that you are not passing milliseconds where seconds are expected (60000 is valid but means about 16 hours).

Example fix

# before
executor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=0)

# after
timeout = int(os.getenv("EXEC_TIMEOUT", "60")) or 60
executor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=max(1, timeout))
Defensive patterns

Strategy: validation

Validate before calling

def valid_timeout(t) -> int:
    t = int(t)
    if t < 1:
        raise ValueError("timeout must be >= 1 second")
    return t

Type guard

def is_valid_timeout(t: object) -> bool:
    return isinstance(t, int) and not isinstance(t, bool) and t >= 1

Try / catch

try:
    DockerJupyterCodeExecutor(jupyter_server=server, timeout=t)
except ValueError as e:
    if "Timeout" in str(e):
        executor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=max(1, int(t)))
    else:
        raise

Prevention

When it happens

Trigger: Instantiating DockerJupyterCodeExecutor(jupyter_server=..., timeout=0) or a negative timeout, often from reading timeout out of a config file/env var where the default ended up as 0 or unset.

Common situations: Env-var parsing that yields 0 for missing values (int(os.getenv('TIMEOUT', 0))), configs that previously used milliseconds or None, tests constructing the executor with timeout=0 expecting 'no wait'.

Understand the failure class

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/9ef3b9313f2e11e6. Report an issue: GitHub.