{"record":{"id":"36d7a02e1648cd13","repo":"TauricResearch/TradingAgents","slug":"llm-max-retries-must-be-an-integer-got-value-r","errorCode":null,"errorMessage":"llm_max_retries must be an integer, got {value!r}","messagePattern":"llm_max_retries must be an integer, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tradingagents/graph/trading_graph.py","lineNumber":59,"sourceCode":"from .setup import GraphSetup\nfrom .signal_processing import SignalProcessor\n\nlogger = logging.getLogger(__name__)\n\n\ndef _coerce_max_retries(value):\n    \"\"\"Validate an ``llm_max_retries`` value to a non-negative int.\n\n    Accepts an int or a numeric string (env vars arrive as strings). Rejects\n    booleans and negatives loudly so a misconfiguration fails at startup rather\n    than silently disabling retries.\n    \"\"\"\n    if isinstance(value, bool):\n        raise ValueError(f\"llm_max_retries must be an integer, not a boolean: {value!r}\")\n    try:\n        n = int(value)\n    except (TypeError, ValueError) as exc:\n        raise ValueError(f\"llm_max_retries must be an integer, got {value!r}\") from exc\n    if n < 0:\n        raise ValueError(f\"llm_max_retries must be >= 0, got {n}\")\n    return n\n\n\nclass TradingAgentsGraph:\n    \"\"\"Main class that orchestrates the trading agents framework.\"\"\"\n\n    def __init__(\n        self,\n        selected_analysts=(\"market\", \"social\", \"news\", \"fundamentals\"),\n        debug=False,\n        config: dict[str, Any] = None,\n        callbacks: list | None = None,\n    ):\n        \"\"\"Initialize the trading agents graph and components.\n\n        Args:","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/graph/trading_graph.py#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"Missing config key resolved to None; env var set to a word instead of a number; templating bugs that leave placeholders like '${RETRIES}' unresolved.","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."],"exampleFix":"# before\nTradingAgentsGraph(config={**DEFAULT_CONFIG, 'llm_max_retries': None})\n\n# after\nTradingAgentsGraph(config={**DEFAULT_CONFIG, 'llm_max_retries': 3})","handlingStrategy":"validation","validationCode":"def resolve_max_retries(cfg: dict, default: int = 3) -> int:\n    value = cfg.get('llm_max_retries', default)\n    if value is None:\n        return default\n    if isinstance(value, bool):\n        raise ValueError('llm_max_retries must be an int, not bool')\n    return int(value)","typeGuard":null,"tryCatchPattern":"try:\n    graph = TradingAgentsGraph(config=config)\nexcept ValueError as e:\n    if 'llm_max_retries' in str(e):\n        config['llm_max_retries'] = 3  # sensible default; log the original bad value\n        graph = TradingAgentsGraph(config=config)\n    else:\n        raise","preventionTips":["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."],"tags":["configuration","validation","retries","startup"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}