unslothai/unsloth · error · ValueError
llama-server does not accept the spaces around '{token[:64]}
Error message
llama-server does not accept the spaces around '{token[:64]}': write it as '{flag}' What it means
ValueError from llama_server_args.py:300 — a flag token carries leading/trailing whitespace (token != token.strip()). _flag_name strips before lookup, so a quoted '--top-k ' passed the denylist and arity walk as --top-k but would reach the child with the space attached; llama.cpp looks up the WHOLE token and answers 'error: invalid argument: --top-k' (measured on b10342), naming a flag that looks correct in the log. Only flag-shaped tokens are checked — values (chat templates, grammars) may legitimately end in whitespace.
Source
Thrown at studio/backend/core/inference/llama_server_args.py:300
# model path: that is the one thing the -m / --model denial exists to
# prevent, and it would sidestep the native-path lease as well.
if pending_values <= 0:
raise ValueError(
"extra llama-server args cannot contain a bare value "
f"('{token[:64]}'); every value must follow its flag"
)
pending_values -= 1
if pending_two_value > 0:
pending_two_value -= 1
elif token != token.strip():
# _flag_name strips before it looks anything up, so a quoted "--top-k "
# passed the denylist and the arity walk as --top-k and then went to the
# child with the space still on it. llama.cpp looks the whole token up,
# so it answers "error: invalid argument: --top-k" (measured on b10342),
# naming a flag that looks correct in the log. Only flag-shaped tokens:
# a VALUE may legitimately end in whitespace, a chat template or a
# grammar being the obvious ones.
raise ValueError(
f"llama-server does not accept the spaces around '{token[:64]}': "
f"write it as '{flag}'"
)
elif "=" in token:
# llama.cpp looks the WHOLE token up in its option map, folding only the
# underscore spelling, so "--top-k=20" is not "--top-k" with a value: it
# is an argument it has never heard of. Measured on b10342 and b10360,
# where --top-k=20, --ctx-size=4096 and --flash-attn=on each exit with
# "error: invalid argument". Accepting the GNU spelling here meant the
# switch tore down the resident model and the child then refused to
# start, so it is refused while it is still a 400 with somewhere to go.
# Splitting it here would be a guess: for a switch the value is not one,
# and this module cannot know an ordinary flag's arity.
value = token.partition("=")[2]
raise ValueError(
f"llama-server does not read an attached value: write '{flag}' and "
f"'{value[:32]}' as two separate arguments, not '{token[:64]}'"
)View on GitHub (pinned to 203007d190)
Solutions
- Strip flag tokens before submitting: [t if not t.startswith('-') else t.strip() for t in args] — the error message itself tells you the correct spelling.
- Fix the producer: don't pad flag strings when building argv; only values may carry whitespace.
- Use shlex.split on a properly quoted command line so spaces inside quotes stay on values, not flags.
Example fix
# before extra_args = ["--top-k ", "40"] # trailing space on the flag # after extra_args = ["--top-k", "40"]
Defensive patterns
Strategy: validation
Validate before calling
extra_args = [t.strip() if t.startswith('-') and '=' not in t else t for t in extra_args] Type guard
def flag_is_clean(token) -> bool:
return not token.startswith('-') or token == token.strip() Try / catch
try:
validate_extra_args(args)
except ValueError as e:
if "spaces around" in str(e):
args = [t if not t.startswith('-') else t.strip() for t in args]
validate_extra_args(args)
else:
raise Prevention
- Strip flag tokens (not value tokens) before submitting.
- Do not pad flags when building command strings in f-strings or templates.
- Prefer list-based argv construction over string concatenation + split.
When it happens
Trigger: Passing a quoted flag with an accidental trailing/leading space: '--top-k ' or ' --flash-attn', typically from template-built arg strings or copy-paste where the space before a closing quote survives.
Common situations: f-string / shell building like f"--top-k {k} " then splitting; copy-pasting from docs with stray spaces; JSON config values with trailing whitespace around flag names.
Related errors
- extra llama-server args cannot contain a bare value ('{token
- llama-server does not read an attached value: write '{flag}'
- llama-server flag '{two_value_flag}' takes two values
- too many extra llama-server args (limit {MAX_EXTRA_ARG_TOKEN
- extra llama-server args are too large (limit {limit} bytes)
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/cdd360f6bb0f1011.
Report an issue: GitHub.