TradingAgents/tests
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
..
test_google_api_key.py refactor: simplify api_key mapping and consolidate tests 2026-03-24 14:52:51 +01:00
test_hallucination_guard.py fix: suppress memory injection when memory is empty (hallucination guard, closes #572) 2026-04-18 22:30:31 -04:00
test_memory_persistence.py feat: persist FinancialSituationMemory to disk (#563) 2026-04-18 21:13:14 -04:00
test_model_validation.py sync model validation with cli catalog 2026-03-25 21:23:02 +08:00
test_ticker_symbol_handling.py fix: preserve exchange-qualified tickers across agent prompts 2026-03-21 21:10:13 +08:00