langchain-ai/deepagents · error · ValueError
expected {label} value, got {value!r}
Error message
expected {label} value, got {value!r} What it means
`_parse_number` is the shared helper behind `parse_float` and `parse_int` for optional numeric environment values. When the string cannot be converted, it raises a ValueError saying what kind of value was expected and what was received. It returns the default only when the env value is absent (`None`), not when it is malformed.
Source
Thrown at libs/talon/deepagents_talon/channels/base.py:397
ValueError: If `value` is not an integer.
"""
return _parse_number(int, value, default, label="integer")
def _parse_number[T](
convert: Callable[[str], T],
value: str | None,
default: T,
*,
label: str,
) -> T:
if value is None:
return default
try:
return convert(value) # type: ignore[return-value]
except ValueError as error:
msg = f"expected {label} value, got {value!r}"
raise ValueError(msg) from error
def split_csv(value: str) -> list[str]:
"""Split a comma-separated environment value.
Args:
value: Raw comma-separated value.
Returns:
Non-empty, stripped items.
"""
return [item.strip() for item in value.split(",") if item.strip()]
def optional_str(value: object) -> str | None:
"""Return a non-empty string value, or ``None``.
Args:View on GitHub (pinned to a1af029e6e)
Solutions
- Set a bare numeric value (`30`, `1.5`) without units or thousand separators.
- Remove the variable so the documented default applies.
- Catch the ValueError at startup to report the misconfigured variable name and value.
Example fix
# before DEEPAGENTS_TALON_TELEGRAM_TIMEOUT=30s # after DEEPAGENTS_TALON_TELEGRAM_TIMEOUT=30
Defensive patterns
Strategy: validation
Validate before calling
import os, re
def require_number(name: str) -> None:
raw = os.environ.get(name)
if raw is not None and not re.fullmatch(r'-?[0-9]+(\.[0-9]+)?', raw.strip()):
raise SystemExit(f'{name} must be a plain number, got {raw!r}') Try / catch
try:
timeout = parse_int(env.get('MY_TIMEOUT'), 30)
except ValueError as exc:
raise SystemExit(f'bad config: {exc}') from exc Prevention
- Never include units in numeric env vars; put the unit in the var name (TIMEOUT_SECONDS).
- Use dots for decimals, never locale commas.
- Wrap parse_float/parse_int calls in a startup config loader that reports the variable name.
When it happens
Trigger: Calling `parse_float`/`parse_int` (used by `from_talon_config` for provider settings like timeouts/poll intervals) with an env string that `float()`/`int()` cannot parse, e.g. `'30s'`, `'1,5'`, or `'high'`.
Common situations: Including units (`30s`, `5m`) in numeric env vars; locale decimal commas; booleans or words where numbers are expected.
Related errors
- Invalid JSON syntax in {manifest_path}: {exc}
- {config.provider} self exposure requires {operator_var}; set
- {MAX_MEDIA_BYTES_ENV} must be a positive integer byte count
- invalid {provider} exposure mode {value!r}; expected one of:
- modes can only be provided when agent is a factory
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/eb45cea00abd09e3.
Report an issue: GitHub.