TauricResearch/TradingAgents · error · ValueError
expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), g
Error message
expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), got {value!r} What it means
ValueError raised by _coerce in tradingagents/default_config.py when a TRADINGAGENTS_* env var mapped to a boolean config key holds a string that is not in the accepted true/false sets. Invalid values fail loudly at startup instead of silently falling back — a misspelled 'treu' would otherwise misconfigure an unattended run.
Source
Thrown at tradingagents/default_config.py:48
_BOOL_TRUE = ("true", "1", "yes", "on")
_BOOL_FALSE = ("false", "0", "no", "off")
def _coerce(value: str, reference):
"""Coerce env-var string to the type of the existing default value.
Invalid values raise ``ValueError`` rather than silently falling back to a
default — a misspelled boolean (e.g. ``treu``) or non-numeric int should fail
loudly at startup, not quietly misconfigure an unattended run.
"""
if isinstance(reference, bool):
normalized = value.strip().lower()
if normalized in _BOOL_TRUE:
return True
if normalized in _BOOL_FALSE:
return False
raise ValueError(
f"expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), got {value!r}"
)
if isinstance(reference, int) and not isinstance(reference, bool):
return int(value)
if isinstance(reference, float):
return float(value)
return value
def _apply_env_overrides(config: dict) -> dict:
"""Apply TRADINGAGENTS_* env vars to the config dict in-place."""
for env_var, key in _ENV_OVERRIDES.items():
raw = os.environ.get(env_var)
if raw is None or raw == "":
continue
try:
config[key] = _coerce(raw, config.get(key))
except ValueError as exc:View on GitHub (pinned to a33fd4c0f1)
Solutions
- Check the error's accepted token list (the _BOOL_TRUE/_BOOL_FALSE values shown in the message) and use one of those spellings.
- Audit your .env / CI secrets for the offending TRADINGAGENTS_* variable and fix the value.
- Standardize on lowercase 'true'/'false' for every boolean env var in your deployment.
Example fix
# before export TRADINGAGENTS_DEBUG=treu # after export TRADINGAGENTS_DEBUG=true
Defensive patterns
Strategy: validation
Validate before calling
_BOOL_TRUE = {'true', '1', 'yes', 'on'}
_BOOL_FALSE = {'false', '0', 'no', 'off'}
def is_valid_bool_env(raw: str | None) -> bool:
return raw is None or raw == '' or raw.strip().lower() in _BOOL_TRUE | _BOOL_FALSE
assert is_valid_bool_env('true') and not is_valid_bool_env('treu') Try / catch
try:
import tradingagents.default_config
except ValueError as e:
print(f'config error at import: {e}') # name the bad TRADINGAGENTS_* var and exit fast
raise SystemExit(2) Prevention
- Standardize on lowercase 'true'/'false' across your env tooling.
- Lint .env files for boolean keys against accepted tokens in CI.
- Fail the deploy when import-time validation raises instead of catching and continuing.
When it happens
Trigger: Setting a boolean env var (e.g. TRADINGAGENTS_BACKEND_URL-check style boolean keys) to a non-recognized spelling such as 'treu', 'yes', '1', or 'enabled' — anything not in the _BOOL_TRUE/_BOOL_FALSE token sets. _coerce is called from _apply_env_overrides during module import.
Common situations: Typos in .env files or CI environment variables; using 'yes'/'no' or '1'/'0' when the library expects 'true'/'false'; shell-exported debug flags with wrong casing or trailing characters.
Related errors
- Invalid value for {env_var}: {exc}
- llm_max_retries must be an integer, not a boolean: {value!r}
- llm_max_retries must be an integer, got {value!r}
- llm_max_retries must be >= 0, got {n}
- unknown analyst key: {analyst_key}
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/ab4f8305c46bdebc.
Report an issue: GitHub.