TauricResearch/TradingAgents · error · ValueError
unknown analyst key: {analyst_key}
Error message
unknown analyst key: {analyst_key} What it means
ValueError raised by build_analyst_execution_plan (tradingagents/graph/analyst_execution.py) when one of the selected_analysts strings has no entry in the ANALYST_NODE_SPECS registry. Valid keys are the fixed analyst names the graph knows how to run (market, social, news, fundamentals). Any other string — wrong casing, abbreviation, typo — fails immediately.
Source
Thrown at tradingagents/graph/analyst_execution.py:63
),
"fundamentals": AnalystNodeSpec(
key="fundamentals",
agent_node="Fundamentals Analyst",
clear_node="Msg Clear Fundamentals",
tool_node="tools_fundamentals",
report_key="fundamentals_report",
),
}
def build_analyst_execution_plan(
selected_analysts: Iterable[str],
) -> AnalystExecutionPlan:
specs: list[AnalystNodeSpec] = []
for analyst_key in selected_analysts:
spec = ANALYST_NODE_SPECS.get(analyst_key)
if spec is None:
raise ValueError(f"unknown analyst key: {analyst_key}")
specs.append(spec)
if not specs:
raise ValueError("at least one analyst must be selected")
return AnalystExecutionPlan(specs=specs)
def get_initial_analyst_node(plan: AnalystExecutionPlan) -> str:
return plan.specs[0].agent_node
class AnalystWallTimeTracker:
def __init__(self, plan: AnalystExecutionPlan):
self.plan = plan
self._started_at: dict[str, float] = {}
self._wall_times: dict[str, float] = {}
View on GitHub (pinned to a33fd4c0f1)
Solutions
- Use the exact registry keys: 'market', 'social', 'news', 'fundamentals' (check ANALYST_NODE_SPECS for the authoritative set).
- Validate/normalize the list against ANALYST_NODE_SPECS before constructing the graph.
- After upgrading the package, re-check the supported analyst keys if your config worked before.
Example fix
# before
TradingAgentsGraph(selected_analysts=('markets', 'news'))
# after
TradingAgentsGraph(selected_analysts=('market', 'news')) Defensive patterns
Strategy: validation
Validate before calling
from tradingagents.graph.analyst_execution import ANALYST_NODE_SPECS
def normalize_analysts(selected) -> tuple[str, ...]:
keys = tuple(a.strip().lower() for a in selected)
unknown = [a for a in keys if a not in ANALYST_NODE_SPECS]
if unknown:
raise ValueError(f'unknown analysts {unknown}; valid: {sorted(ANALYST_NODE_SPECS)}')
return keys Try / catch
try:
graph = TradingAgentsGraph(selected_analysts=selected)
except ValueError as e:
if 'unknown analyst key' in str(e):
selected = ('market', 'news') # or surface the valid-keys error to the user
graph = TradingAgentsGraph(selected_analysts=selected)
else:
raise Prevention
- Source analyst names from ANALYST_NODE_SPECS, never hardcode them in app config.
- Normalize case/whitespace on analyst input from users or YAML.
- Re-validate your config after package upgrades.
When it happens
Trigger: Passing selected_analysts=('markets', 'news') or ('mkt',) to TradingAgentsGraph / build_analyst_execution_plan; also forwarding user or LLM-provided analyst names without validation.
Common situations: Typos or plural forms ('markets' vs 'market'), renamed keys after upgrading the library, config files carrying outdated analyst lists, case-sensitive mismatches ('Market').
Related errors
- at least one analyst must be selected
- expected a boolean ({'/'.join(_BOOL_TRUE + _BOOL_FALSE)}), g
- 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}
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/c26e1521d916b597.
Report an issue: GitHub.