{"record":{"id":"213ee6c8b63f7ca7","repo":"hsliuping/TradingAgents-CN","slug":"trading-agents-graph-setup-error-no-analysts-sele","errorCode":null,"errorMessage":"Trading Agents Graph Setup Error: no analysts selected!","messagePattern":"Trading Agents Graph Setup Error: no analysts selected!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tradingagents/graph/setup.py","lineNumber":78,"sourceCode":"        self.risk_manager_memory = risk_manager_memory\n        self.conditional_logic = conditional_logic\n        self.config = config or {}\n        self.react_llm = react_llm\n\n    def setup_graph(\n        self, selected_analysts=[\"market\", \"social\", \"news\", \"fundamentals\"]\n    ):\n        \"\"\"Set up and compile the agent workflow graph.\n\n        Args:\n            selected_analysts (list): List of analyst types to include. Options are:\n                - \"market\": Market analyst\n                - \"social\": Social media analyst\n                - \"news\": News analyst\n                - \"fundamentals\": Fundamentals analyst\n        \"\"\"\n        if len(selected_analysts) == 0:\n            raise ValueError(\"Trading Agents Graph Setup Error: no analysts selected!\")\n\n        # Create analyst nodes\n        analyst_nodes = {}\n        delete_nodes = {}\n        tool_nodes = {}\n\n        if \"market\" in selected_analysts:\n            # 现在所有LLM都使用标准市场分析师（包括阿里百炼的OpenAI兼容适配器）\n            llm_provider = self.config.get(\"llm_provider\", \"\").lower()\n\n            # 检查是否使用OpenAI兼容的阿里百炼适配器\n            using_dashscope_openai = (\n                \"dashscope\" in llm_provider and\n                hasattr(self.quick_thinking_llm, '__class__') and\n                'OpenAI' in self.quick_thinking_llm.__class__.__name__\n            )\n\n            if using_dashscope_openai:","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/graph/setup.py#L60-L96","documentation":"This error is thrown by setup_graph in tradingagents/graph/setup.py when the selected_analysts argument is an empty collection. The graph builder requires at least one analyst type (market, social, news, fundamentals) to construct analyst nodes; with none selected there is nothing to propagate through the graph. It is a fail-fast guard against constructing a useless agent pipeline.","triggerScenarios":"Calling setup_graph(selected_analysts=[]) or TrajectoryGraph/TradingAgentsGraph with an empty analysts list, or filtering analysts from config (e.g. only keeping analysts whose flag is False) until none remain.","commonSituations":"Default config has all analyst booleans set to false; a UI passes an empty multi-select; programmatic filtering (e.g. [a for a in analysts if enabled[a]]) yields an empty list due to naming mismatch or wrong keys.","solutions":["Pass at least one valid analyst: selected_analysts=[\"market\"] (valid values: market, social, news, fundamentals)","Check the config keys that feed the analysts selection before calling the constructor and log the resolved list","If using a UI/web layer, default-select at least one analyst so the list can never be empty"],"exampleFix":"// before\nanalysts = [a for a in [\"market\",\"social\",\"news\",\"fundamentals\"] if cfg.get(a, False)]\nsetup_graph(selected_analysts=analysts, ...)\n\n// after\nanalysts = [a for a in [\"market\",\"social\",\"news\",\"fundamentals\"] if cfg.get(a, False)]\nif not analysts:\n    analysts = [\"market\"]  # sane default\nsetup_graph(selected_analysts=analysts, ...)","handlingStrategy":"validation","validationCode":"VALID = {\"market\", \"social\", \"news\", \"fundamentals\"}\nselected = [a for a in cfg.get(\"analysts\", []) if a in VALID]\nif not selected:\n    selected = [\"market\"]\nsetup_graph(selected_analysts=selected, ...)","typeGuard":"def is_nonempty_analyst_list(v) -> bool:\n    return isinstance(v, (list, tuple, set)) and len(v) > 0 and all(a in {\"market\",\"social\",\"news\",\"fundamentals\"} for a in v)","tryCatchPattern":null,"preventionTips":["Default-select at least one analyst in UI/config code","Whitelist analyst names before passing to setup_graph to catch typos","Log the resolved analyst list before graph construction"],"tags":["configuration","validation","graph-setup","tradingagents"],"backgroundTag":"empty-selection-validation","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}