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 DockerCommandLineCodeExecutor: the `timeout` argument (seconds allowed per code block execution) must be >= 1. Passing 0 or a negative number fails immediately at object construction, before any Docker interaction.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py:183
bind_dir: Optional[Union[Path, str]] = None,
auto_remove: bool = True,
stop_container: bool = True,
device_requests: Optional[List[DeviceRequest]] = None,
functions: Sequence[
Union[
FunctionWithRequirements[Any, A],
Callable[..., Any],
FunctionWithRequirementsStr,
]
] = [],
functions_module: str = "functions",
extra_volumes: Optional[Dict[str, Dict[str, str]]] = None,
extra_hosts: Optional[Dict[str, str]] = None,
init_command: Optional[str] = None,
delete_tmp_files: bool = False,
):
if timeout < 1:
raise ValueError("Timeout must be greater than or equal to 1.")
# Handle working directory logic
if work_dir is None:
self._work_dir = None
else:
if isinstance(work_dir, str):
work_dir = Path(work_dir)
# Emit a deprecation warning if the user is using the current directory as working directory
if work_dir.resolve() == Path.cwd().resolve():
warnings.warn(
"Using the current directory as work_dir is deprecated.",
DeprecationWarning,
stacklevel=2,
)
self._work_dir = work_dir
# Create the working directory if it doesn't exist
self._work_dir.mkdir(exist_ok=True, parents=True)
View on GitHub (pinned to 027ecf0a37)
Solutions
- Pass an explicit positive timeout: timeout=60 (the default)
- Fix the upstream config so unset timeouts fall back to a default rather than 0: `timeout = cfg.timeout or 60`
- Validate user-supplied config before constructing the executor
Example fix
# before executor = DockerCommandLineCodeExecutor(timeout=cfg.timeout) # cfg.timeout == 0 # after executor = DockerCommandLineCodeExecutor(timeout=cfg.timeout if cfg.timeout and cfg.timeout >= 1 else 60)
Defensive patterns
Strategy: validation
Validate before calling
def sane_timeout(cfg) -> int:
t = cfg.get("timeout") or 60
if not isinstance(t, int) or t < 1:
raise ValueError(f"timeout must be >= 1, got {t!r}")
return t Type guard
def is_valid_timeout(t) -> bool:
return isinstance(t, (int, float)) and not isinstance(t, bool) and t >= 1 Try / catch
null
Prevention
- Default config values to 60, never 0/None-then-0
- Validate user-facing config at load time so constructor validation never fires
When it happens
Trigger: Instantiating DockerCommandLineCodeExecutor(timeout=0) or timeout=-5, or computing timeout from a config value that defaults to 0 (e.g. an unset settings field) and passing it straight through.
Common situations: Config-driven constructors where timeout is Optional[int] defaulting to 0/None and 0 is passed instead of a sensible default; copy-pasting from LocalCommandLineCodeExecutor examples that used fractional seconds; CI configs parsing 'timeout' from an empty env var as 0.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Unsupported config type {config.GetType()}
- Module name must be a valid Python identifier
- Messages should not be provided in options
- Invalid AgentId type: '{type}'. Must be alphanumeric (a-z, 0
- Maximum number of tool iterations must be greater than or eq
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/2534228f7700b0c2.
Report an issue: GitHub.