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 LocalCommandLineCodeExecutor: timeout (seconds per command, default 60) must be >= 1. Zero/negative raises ValueError right after the safety UserWarning about executing code locally.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py:172
Callable[..., Any],
FunctionWithRequirementsStr,
]
] = [],
functions_module: str = "functions",
cleanup_temp_files: bool = True,
virtual_env_context: Optional[SimpleNamespace] = None,
):
# Issue warning about using LocalCommandLineCodeExecutor
warnings.warn(
"Using LocalCommandLineCodeExecutor may execute code on the local machine which can be unsafe. "
"For security, it is recommended to use DockerCommandLineCodeExecutor instead. "
"To install Docker, visit: https://docs.docker.com/get-docker/",
UserWarning,
stacklevel=2,
)
if timeout < 1:
raise ValueError("Timeout must be greater than or equal to 1.")
self._timeout = timeout
self._work_dir: Optional[Path] = None
if work_dir is not None:
# Check if user provided work_dir is the current directory and warn if so.
if Path(work_dir).resolve() == Path.cwd().resolve():
warnings.warn(
"Using the current directory as work_dir is deprecated.",
DeprecationWarning,
stacklevel=2,
)
if isinstance(work_dir, str):
self._work_dir = Path(work_dir)
else:
self._work_dir = work_dir
self._work_dir.mkdir(exist_ok=True)
self._functions = functionsView on GitHub (pinned to 027ecf0a37)
Solutions
- Pass timeout >= 1 second (e.g. default 60).
- Clamp externally sourced values: timeout = max(1, int(raw)).
- If you actually want short waits, use a small positive value like 5, not 0.
Example fix
# before executor = LocalCommandLineCodeExecutor(timeout=0) # after executor = LocalCommandLineCodeExecutor(timeout=60)
Defensive patterns
Strategy: validation
Validate before calling
timeout = int(os.getenv("LOCAL_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:
LocalCommandLineCodeExecutor(timeout=t)
except ValueError as e:
if "Timeout" in str(e):
executor = LocalCommandLineCodeExecutor(timeout=max(1, int(t)))
else:
raise Prevention
- Clamp config-sourced timeouts with max(1, ...).
- Remember units are seconds; document it next to config keys.
When it happens
Trigger: LocalCommandLineCodeExecutor(timeout=0) or a negative timeout, usually from config/env parsing that yields 0 when unset or from millisecond-vs-second confusion.
Common situations: Defaults like int(os.getenv('LOCAL_TIMEOUT', 0)) when the var is unset, passing 60_000 (milliseconds) which silently works but means about 16 hours, computed timeouts underflowing to 0, tests with timeout=0 expecting immediate abort.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Module name must be a valid Python identifier
- Unsupported config type {config.GetType()}
- Messages should not be provided in options
- The agent name must be a valid Python identifier.
- model_client.model_info must be provided when max_retries_on
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/51bed7d47cdd1961.
Report an issue: GitHub.