hsliuping/TradingAgents-CN · error · ValueError

Trading Agents Graph Setup Error: no analysts selected!

Error message

Trading Agents Graph Setup Error: no analysts selected!

What it means

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.

Source

Thrown at tradingagents/graph/setup.py:78

        self.risk_manager_memory = risk_manager_memory
        self.conditional_logic = conditional_logic
        self.config = config or {}
        self.react_llm = react_llm

    def setup_graph(
        self, selected_analysts=["market", "social", "news", "fundamentals"]
    ):
        """Set up and compile the agent workflow graph.

        Args:
            selected_analysts (list): List of analyst types to include. Options are:
                - "market": Market analyst
                - "social": Social media analyst
                - "news": News analyst
                - "fundamentals": Fundamentals analyst
        """
        if len(selected_analysts) == 0:
            raise ValueError("Trading Agents Graph Setup Error: no analysts selected!")

        # Create analyst nodes
        analyst_nodes = {}
        delete_nodes = {}
        tool_nodes = {}

        if "market" in selected_analysts:
            # 现在所有LLM都使用标准市场分析师(包括阿里百炼的OpenAI兼容适配器)
            llm_provider = self.config.get("llm_provider", "").lower()

            # 检查是否使用OpenAI兼容的阿里百炼适配器
            using_dashscope_openai = (
                "dashscope" in llm_provider and
                hasattr(self.quick_thinking_llm, '__class__') and
                'OpenAI' in self.quick_thinking_llm.__class__.__name__
            )

            if using_dashscope_openai:

View on GitHub (pinned to 74783e8817)

Solutions

  1. Pass at least one valid analyst: selected_analysts=["market"] (valid values: market, social, news, fundamentals)
  2. Check the config keys that feed the analysts selection before calling the constructor and log the resolved list
  3. If using a UI/web layer, default-select at least one analyst so the list can never be empty

Example fix

// before
analysts = [a for a in ["market","social","news","fundamentals"] if cfg.get(a, False)]
setup_graph(selected_analysts=analysts, ...)

// after
analysts = [a for a in ["market","social","news","fundamentals"] if cfg.get(a, False)]
if not analysts:
    analysts = ["market"]  # sane default
setup_graph(selected_analysts=analysts, ...)
Defensive patterns

Strategy: validation

Validate before calling

VALID = {"market", "social", "news", "fundamentals"}
selected = [a for a in cfg.get("analysts", []) if a in VALID]
if not selected:
    selected = ["market"]
setup_graph(selected_analysts=selected, ...)

Type guard

def is_nonempty_analyst_list(v) -> bool:
    return isinstance(v, (list, tuple, set)) and len(v) > 0 and all(a in {"market","social","news","fundamentals"} for a in v)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hsliuping/TradingAgents-CN@74783e8817 (2026-08-28). Data as JSON: /api/errors/213ee6c8b63f7ca7. Report an issue: GitHub.