fix(agents): record the decision that was made, or flag it for review

- the labelled rating decides, whatever dash separates it, and a scale the model echoed is not one
- prose naming several ratings is reviewed rather than read as the first word in the text
- an unreadable decision is tagged REVIEW everywhere instead of a tradeable Hold
- unrated decisions are counted apart from the backtest figures
This commit is contained in:
Yijia-Xiao
2026-09-17 05:00:08 +00:00
parent 3244a568ed
commit 8d30fee06b
6 changed files with 268 additions and 30 deletions

View File

@@ -193,10 +193,14 @@ class TestTradingMemoryLogCore:
log.store_decision("AAPL", "2026-01-11", DECISION_OVERWEIGHT)
assert log.load_entries()[0]["rating"] == "Overweight"
def test_rating_fallback_hold(self, tmp_path):
def test_an_unreadable_decision_is_tagged_for_review(self, tmp_path):
"""Not a Hold: a fabricated rating is quoted back to the next run as a
call that was never made, and counted in the backtest figures."""
from tradingagents.agents.utils.rating import RATING_REVIEW
log = make_log(tmp_path)
log.store_decision("MSFT", "2026-01-12", DECISION_NO_RATING)
assert log.load_entries()[0]["rating"] == "Hold"
assert log.load_entries()[0]["rating"] == RATING_REVIEW
def test_rating_priority_over_prose(self, tmp_path):
"""'Rating: X' label wins even when an opposing rating word appears earlier in prose."""