BerriAI/litellm · error · AgentRunError
Cannot pass an argument containing a line break to `{os.path
Error message
Cannot pass an argument containing a line break to `{os.path.basename(path)}` on Windows: cmd.exe ends the command line there, so the agent would silently lose it. What it means
Windows quoting guard in the agent launcher: a forwarded argument contains a newline, which cmd.exe treats as a command-line terminator, so the agent would silently lose the remainder of its arguments; the call is rejected instead.
Source
Thrown at litellm/proxy/client/cli/commands/agents.py:194
resolve but CreateProcess refuses to run (WinError 193), so a shim has to go
through the command processor. cmd.exe does not follow the C runtime quoting
that subprocess would apply to an argument list, and it would split on `&` or
`|` in a forwarded argument, so the shim case is emitted as one verbatim
command line with every token quoted. Every switch is load-bearing: `/s`
makes cmd strip only the outer pair, leaving each token quoted and its
metacharacters inert, `/e:on` keeps the command extensions that the percent
guard is built out of, `/v:off` keeps `!` from expanding, and `/d` keeps a
machine's AutoRun commands out of the launch. argv[0] carries the
caller-facing name on POSIX; Windows needs the resolved path there.
Raises AgentRunError for an argument holding a line break, which cmd would
read as the end of the command line and silently drop the rest of.
"""
rest: Final = tuple(args[1:])
if os.path.splitext(path)[1].lower() not in _WINDOWS_SHIM_SUFFIXES:
return (path, *rest)
if any(brk in token for token in rest for brk in _CMD_LINE_BREAKS):
raise AgentRunError(
f"Cannot pass an argument containing a line break to `{os.path.basename(path)}` on "
"Windows: cmd.exe ends the command line there, so the agent would silently lose it."
)
inner: Final = " ".join(_quote_for_cmd(token) for token in (path, *rest))
return f'cmd.exe /d /e:on /v:off /s /c "{inner}"'
def _spawn_and_wait(command: str | Sequence[str], env: Mapping[str, str]) -> int:
return subprocess.run(command, env=dict(env), check=False).returncode
def _replace_process(
path: str,
args: Sequence[str],
env: Mapping[str, str],
*,
execvpe: Callable[..., None] = os.execvpe,
) -> None:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Remove line breaks from the argument value.
- Pass multi-line content via a file instead of a command-line argument.
Example fix
Replace embedded newlines with spaces before passing the argument on Windows.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/client/cli/commands/agents.py:194 when the library encounters an invalid state.
Common situations: An argument containing a newline was passed on Windows where cmd.exe truncates the command line.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/bb632f18b834d0d6.
Report an issue: GitHub.