TradingAgents/tradingagents/agents/utils
Zhigong Liu 2cdada6300 fix: suppress memory injection when memory is empty (hallucination guard, closes #572)
When past_memories is empty, all five agents previously injected an
empty string into their prompts while still instructing the LLM to
"address reflections and learn from past mistakes" — causing the LLM
to hallucinate fabricated lessons on first run.

Each agent now conditionally builds its memory section only when
past_memories is non-empty, so the injection and its instruction
are both absent when there is nothing to recall.

Also fixes import ordering in memory.py (logger after imports).

Tests: tests/test_hallucination_guard.py covers empty and populated
memory for all five agents (bull, bear, trader, research manager,
portfolio manager).

Companion to #563 (memory persistence).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 22:30:31 -04:00
..
agent_states.py refactor: remove stale imports, use configurable results path (#499) 2026-04-04 07:35:35 +00:00
agent_utils.py feat: multi-language output support for analyst reports and final decision (#472) 2026-03-29 19:19:01 +00:00
core_stock_tools.py minor fix 2025-09-26 23:25:33 +08:00
fundamental_data_tools.py minor fix 2025-09-26 23:25:33 +08:00
memory.py fix: suppress memory injection when memory is empty (hallucination guard, closes #572) 2026-04-18 22:30:31 -04:00
news_data_tools.py fix: improve data vendor implementations and tool signatures 2026-02-03 22:27:20 +00:00
technical_indicators_tools.py fix: normalize indicator names to lowercase (#490) 2026-04-04 07:23:31 +00:00