langchain-ai/deepagents · error · ValueError
--model-params requires a JSON object value
Error message
--model-params requires a JSON object value
What it means
_extract_model_params_flag parses the value following the --model-params CLI flag. When there is nothing after the flag (only whitespace or end of input), it cannot build a JSON object and raises ValueError. The flag requires a JSON object payload such as {"temperature":0.2}.
Source
Thrown at libs/code/deepagents_code/app.py:1934
Tuple of `(remaining_args, parsed_dict | None)`. Returns `None` for the
dict when the flag is absent.
Raises:
ValueError: If the value is missing, has unclosed quotes,
unbalanced braces, or is not valid JSON.
TypeError: If the parsed JSON is not a dict.
"""
flag = "--model-params"
idx = raw_arg.find(flag)
if idx == -1:
return raw_arg, None
before = raw_arg[:idx].rstrip()
after = raw_arg[idx + len(flag) :].lstrip()
if not after:
msg = "--model-params requires a JSON object value"
raise ValueError(msg)
# Determine the JSON string boundaries.
if after[0] in {"'", '"'}:
quote = after[0]
end = -1
backslash_count = 0
for i, ch in enumerate(after[1:], start=1):
if ch == "\\":
backslash_count += 1
continue
if ch == quote and backslash_count % 2 == 0:
end = i
break
backslash_count = 0
if end == -1:
msg = f"Unclosed {quote} in --model-params value"
raise ValueError(msg)
# Parse the quoted token with shlex so escaped quotes are unescaped.View on GitHub (pinned to a1af029e6e)
Solutions
- Append a JSON object after the flag: --model-params '{"temperature":0.2}'.
- Quote the JSON if your shell strips braces, and verify the variable feeding the flag is non-empty.
- If the value comes from a script, echo it first to confirm it expands to a JSON object.
Example fix
# before
dcode --model-params
# after
dcode --model-params '{"temperature": 0.2}' Defensive patterns
Strategy: try-catch
Validate before calling
parts = shlex.split(cmd)
if "--model-params" in parts and parts.index("--model-params") == len(parts) - 1:
raise SystemExit("--model-params needs a JSON object value") Try / catch
try:
handle_command(argv)
except ValueError as e:
if "--model-params" in str(e):
print(f"usage: --model-params '<json object>' — {e}")
sys.exit(2)
raise Prevention
- Always pass the JSON object in single quotes on the same line as the flag.
- Validate the payload with json.loads before invoking the CLI.
- Never template --model-params with a possibly-empty variable.
When it happens
Trigger: Invoking the CLI with --model-params as the last token, e.g. `dcode --model-params`, or with the flag followed only by whitespace.
Common situations: Copy-pasting a command where the JSON value ended up on a second line that the shell dropped; a script template where the JSON variable was empty; forgetting the value while exploring flags interactively.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Unbalanced braces in --model-params value
- enable_interpreter=True is not supported with a remote sandb
- Unclosed {quote} in --model-params value
- Error: Could not read the skill trust store: {exc}
- Error: Invalid agent name: {error_msg}
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/c04efbb5009185a6.
Report an issue: GitHub.