TauricResearch/TradingAgents · error · ValueError
llm_max_retries must be an integer, got {value!r}
Error message
llm_max_retries must be an integer, got {value!r} What it means
ValueError raised by _coerce_max_retries when the llm_max_retries value cannot be converted to int at all — e.g. None, a non-numeric string like 'many', or a list. The conversion int(value) raises TypeError/ValueError and is re-raised with a clear message so the misconfiguration surfaces at graph construction, not as a mysterious crash mid-run.
Source
Thrown at tradingagents/graph/trading_graph.py:59
from .setup import GraphSetup
from .signal_processing import SignalProcessor
logger = logging.getLogger(__name__)
def _coerce_max_retries(value):
"""Validate an ``llm_max_retries`` value to a non-negative int.
Accepts an int or a numeric string (env vars arrive as strings). Rejects
booleans and negatives loudly so a misconfiguration fails at startup rather
than silently disabling retries.
"""
if isinstance(value, bool):
raise ValueError(f"llm_max_retries must be an integer, not a boolean: {value!r}")
try:
n = int(value)
except (TypeError, ValueError) as exc:
raise ValueError(f"llm_max_retries must be an integer, got {value!r}") from exc
if n < 0:
raise ValueError(f"llm_max_retries must be >= 0, got {n}")
return n
class TradingAgentsGraph:
"""Main class that orchestrates the trading agents framework."""
def __init__(
self,
selected_analysts=("market", "social", "news", "fundamentals"),
debug=False,
config: dict[str, Any] = None,
callbacks: list | None = None,
):
"""Initialize the trading agents graph and components.
Args:View on GitHub (pinned to a33fd4c0f1)
Solutions
- Set the value to a concrete non-negative integer or numeric string.
- Ensure config resolution never passes None — give it a default (e.g. 3) when the key is absent.
- Check for unresolved placeholder strings like '${RETRIES}' in your deployment.
Example fix
# before
TradingAgentsGraph(config={**DEFAULT_CONFIG, 'llm_max_retries': None})
# after
TradingAgentsGraph(config={**DEFAULT_CONFIG, 'llm_max_retries': 3}) Defensive patterns
Strategy: validation
Validate before calling
def resolve_max_retries(cfg: dict, default: int = 3) -> int:
value = cfg.get('llm_max_retries', default)
if value is None:
return default
if isinstance(value, bool):
raise ValueError('llm_max_retries must be an int, not bool')
return int(value) Try / catch
try:
graph = TradingAgentsGraph(config=config)
except ValueError as e:
if 'llm_max_retries' in str(e):
config['llm_max_retries'] = 3 # sensible default; log the original bad value
graph = TradingAgentsGraph(config=config)
else:
raise Prevention
- Give llm_max_retries an explicit numeric default wherever config might omit it.
- Fail fast on None from config resolution — don't forward it.
- Check for unresolved '${...}' placeholders in templated configs.
When it happens
Trigger: Passing llm_max_retries=None, 'unlimited', '' (empty string from an env var that slipped past empty-checks elsewhere), or any non-numeric object to TradingAgentsGraph.
Common situations: Missing config key resolved to None; env var set to a word instead of a number; templating bugs that leave placeholders like '${RETRIES}' unresolved.
Related errors
- llm_max_retries must be an integer, not a boolean: {value!r}
- llm_max_retries must be >= 0, got {n}
- expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), g
- Invalid value for {env_var}: {exc}
- unknown analyst key: {analyst_key}
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/36d7a02e1648cd13.
Report an issue: GitHub.