Skip to content
Python

fix(analysts): align the news prompt with the get_news tool signature

Yijia-Xiao622f99d28a39
diff --git a/tests/test_news_analyst_prompt.py b/tests/test_news_analyst_prompt.py
new file mode 100644
index 000000000..bc29ae9a6
--- /dev/null
+++ b/tests/test_news_analyst_prompt.py
@@ -0,0 +1,25 @@
+"""Guard the news analyst prompt against tool-signature drift (#1116).
+
+The prompt used to advertise ``get_news(query, ...)`` while the tool takes a
+``ticker``, tricking the LLM into hallucinating free-text query calls.
+"""
+import inspect
+
+import pytest
+
+import tradingagents.agents.analysts.news_analyst as na
+from tradingagents.agents.utils.news_data_tools import get_news
+
+
+def test_get_news_takes_ticker_not_query():
+ arg_names = set(get_news.args.keys())
+ assert "ticker" in arg_names
+ assert "query" not in arg_names
+
+
+def test_news_prompt_matches_get_news_signature():
+ src = inspect.getsource(na)
+ assert "get_news(ticker, start_date, end_date)" in src
+ assert "get_news(query" not in src
diff --git a/tradingagents/agents/analysts/news_analyst.py b/tradingagents/agents/analysts/news_analyst.py
index 34aaf511f..c2fe20c55 100644
--- a/tradingagents/agents/analysts/news_analyst.py
+++ b/tradingagents/agents/analysts/news_analyst.py
@@ -25,7 +25,7 @@ def create_news_analyst(llm):
]
system_message = (
- f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for {asset_label}-specific or targeted news searches, get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news, get_macro_indicators(indicator, curr_date, look_back_days) to ground macro commentary in actual data from FRED (e.g. 'cpi', 'core_pce', 'unemployment', 'fed_funds_rate', '10y_treasury', 'yield_curve'), and get_prediction_markets(topic, limit) for live market-implied probabilities of forward-looking events (e.g. 'Fed rate cut', 'recession 2026', geopolitical or sector events). Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
+ f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(ticker, start_date, end_date) for {asset_label}-specific news by ticker symbol, get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news, get_macro_indicators(indicator, curr_date, look_back_days) to ground macro commentary in actual data from FRED (e.g. 'cpi', 'core_pce', 'unemployment', 'fed_funds_rate', '10y_treasury', 'yield_curve'), and get_prediction_markets(topic, limit) for live market-implied probabilities of forward-looking events (e.g. 'Fed rate cut', 'recession 2026', geopolitical or sector events). Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ get_language_instruction()
)