From fe9c8d5d31848fcad7d78e04560dfbe6ca98c932 Mon Sep 17 00:00:00 2001 From: Yijia-Xiao Date: Sun, 15 Mar 2026 18:05:36 +0000 Subject: [PATCH] fix: handle comma-separated indicators in get_indicators tool LLMs (especially smaller models) sometimes pass multiple indicator names as a single comma-separated string instead of making separate tool calls. Split and process each individually at the tool boundary. --- .../agents/utils/technical_indicators_tools.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tradingagents/agents/utils/technical_indicators_tools.py b/tradingagents/agents/utils/technical_indicators_tools.py index c6c08bca..77acf09c 100644 --- a/tradingagents/agents/utils/technical_indicators_tools.py +++ b/tradingagents/agents/utils/technical_indicators_tools.py @@ -10,14 +10,22 @@ def get_indicators( look_back_days: Annotated[int, "how many days to look back"] = 30, ) -> str: """ - Retrieve technical indicators for a given ticker symbol. + Retrieve a single technical indicator for a given ticker symbol. Uses the configured technical_indicators vendor. Args: symbol (str): Ticker symbol of the company, e.g. AAPL, TSM - indicator (str): Technical indicator to get the analysis and report of + indicator (str): A single technical indicator name, e.g. 'rsi', 'macd'. Call this tool once per indicator. curr_date (str): The current trading date you are trading on, YYYY-mm-dd look_back_days (int): How many days to look back, default is 30 Returns: str: A formatted dataframe containing the technical indicators for the specified ticker symbol and indicator. """ - return route_to_vendor("get_indicators", symbol, indicator, curr_date, look_back_days) \ No newline at end of file + # LLMs sometimes pass multiple indicators as a comma-separated string; + # split and process each individually. + indicators = [i.strip() for i in indicator.split(",") if i.strip()] + if len(indicators) > 1: + results = [] + for ind in indicators: + results.append(route_to_vendor("get_indicators", symbol, ind, curr_date, look_back_days)) + return "\n\n".join(results) + return route_to_vendor("get_indicators", symbol, indicator.strip(), curr_date, look_back_days) \ No newline at end of file