mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 15:02:39 +03:00
refactor: one name per decision in the state and its log
- the Research Manager's plan and the Portfolio Manager's decision live only in investment_plan and final_trade_decision; the debate states no longer copy them as judge_decision - the saved state log writes the Trader's plan as trader_investment_plan, its state key - the report tree, the final display and the live CLI read the decisions from those fields
This commit is contained in:
@@ -48,9 +48,9 @@ def _state(ticker, final="评级: 买入"):
|
||||
"fundamentals_report": "基本面", "investment_plan": "计划",
|
||||
"trader_investment_plan": "交易计划", "final_trade_decision": final, "final_rating": "REVIEW",
|
||||
"investment_debate_state": {"bull_history": "", "bear_history": "", "history": "",
|
||||
"current_response": "", "judge_decision": "", "count": 0},
|
||||
"current_response": "", "count": 0},
|
||||
"risk_debate_state": {"aggressive_history": "", "conservative_history": "",
|
||||
"neutral_history": "", "history": "", "judge_decision": "",
|
||||
"neutral_history": "", "history": "",
|
||||
"latest_speaker": "", "current_aggressive_response": "",
|
||||
"current_conservative_response": "", "current_neutral_response": "",
|
||||
"count": 0},
|
||||
@@ -76,6 +76,19 @@ def test_the_state_log_keeps_non_ascii_readable(tmp_path):
|
||||
assert json.loads(written) # still valid JSON
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_the_state_log_names_each_field_as_the_state_does(tmp_path):
|
||||
"""One name per field: the Trader's plan under its state key, and no second
|
||||
copy of the managers' decisions under the debate states."""
|
||||
_bare_graph(tmp_path)._log_state("2026-09-01", _state("NVDA"))
|
||||
|
||||
logged = json.loads(next(tmp_path.rglob("full_states_log*.json")).read_text(encoding="utf-8"))
|
||||
assert logged["trader_investment_plan"] == "交易计划"
|
||||
assert logged["investment_plan"] == "计划"
|
||||
assert "trader_investment_decision" not in logged
|
||||
assert "judge_decision" not in json.dumps(logged)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_the_live_display_does_not_scroll_the_terminal():
|
||||
"""A layout taller than the window makes rich redraw by scrolling, which
|
||||
|
||||
@@ -74,7 +74,6 @@ def _make_pm_state(past_context=""):
|
||||
"aggressive_history": "",
|
||||
"conservative_history": "",
|
||||
"neutral_history": "",
|
||||
"judge_decision": "",
|
||||
"current_aggressive_response": "",
|
||||
"current_conservative_response": "",
|
||||
"current_neutral_response": "",
|
||||
@@ -906,13 +905,13 @@ class TestLegacyRemoval:
|
||||
"fundamentals_report": "",
|
||||
"investment_debate_state": {
|
||||
"bull_history": "", "bear_history": "", "history": "",
|
||||
"current_response": "", "judge_decision": "",
|
||||
"current_response": "",
|
||||
},
|
||||
"investment_plan": "",
|
||||
"trader_investment_plan": "",
|
||||
"risk_debate_state": {
|
||||
"aggressive_history": "", "conservative_history": "",
|
||||
"neutral_history": "", "history": "", "judge_decision": "",
|
||||
"neutral_history": "", "history": "",
|
||||
"current_aggressive_response": "", "current_conservative_response": "",
|
||||
"current_neutral_response": "", "count": 1, "latest_speaker": "",
|
||||
},
|
||||
|
||||
@@ -139,11 +139,11 @@ def test_decision_agents_see_the_portfolio(module, factory, monkeypatch):
|
||||
"news_report": "N", "fundamentals_report": "F", "investment_plan": "P",
|
||||
"trader_investment_plan": "T", "past_context": "",
|
||||
"portfolio_context": "PORTFOLIO_BLOCK_MARKER",
|
||||
"investment_debate_state": {"history": "", "judge_decision": "", "count": 0},
|
||||
"investment_debate_state": {"history": "", "count": 0},
|
||||
"risk_debate_state": {"history": "", "latest_speaker": "", "count": 0,
|
||||
"aggressive_history": "", "conservative_history": "", "neutral_history": "",
|
||||
"current_aggressive_response": "", "current_conservative_response": "",
|
||||
"current_neutral_response": "", "judge_decision": ""},
|
||||
"current_neutral_response": ""},
|
||||
}
|
||||
node = getattr(mod, factory)(_LLM())
|
||||
node(state)
|
||||
|
||||
@@ -74,11 +74,11 @@ def test_a_report_that_was_never_produced_says_so(module, factory):
|
||||
"market_report": "RSI 61, price 178.", "sentiment_report": "", "news_report": "",
|
||||
"fundamentals_report": "", "investment_plan": "P", "trader_investment_plan": "T",
|
||||
"investment_debate_state": {"bull_history": "", "bear_history": "", "history": "",
|
||||
"current_response": "", "judge_decision": "", "count": 0},
|
||||
"current_response": "", "count": 0},
|
||||
"risk_debate_state": {"history": "", "latest_speaker": "", "count": 0,
|
||||
"aggressive_history": "", "conservative_history": "", "neutral_history": "",
|
||||
"current_aggressive_response": "", "current_conservative_response": "",
|
||||
"current_neutral_response": "", "judge_decision": ""},
|
||||
"current_neutral_response": ""},
|
||||
}
|
||||
getattr(mod, factory)(_LLM())(state)
|
||||
|
||||
|
||||
@@ -194,11 +194,11 @@ def test_a_decision_prompt_states_the_shape_of_its_answer(module, factory, must_
|
||||
"news_report": "N", "fundamentals_report": "F", "investment_plan": "P",
|
||||
"trader_investment_plan": "T", "past_context": "", "portfolio_context": "",
|
||||
"investment_debate_state": {"bull_history": "b", "bear_history": "r", "history": "h",
|
||||
"current_response": "", "judge_decision": "", "count": 2},
|
||||
"current_response": "", "count": 2},
|
||||
"risk_debate_state": {"history": "h", "latest_speaker": "", "count": 3,
|
||||
"aggressive_history": "", "conservative_history": "", "neutral_history": "",
|
||||
"current_aggressive_response": "", "current_conservative_response": "",
|
||||
"current_neutral_response": "", "judge_decision": ""},
|
||||
"current_neutral_response": ""},
|
||||
}
|
||||
getattr(mod, factory)(_LLM())(state)
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@ def _state():
|
||||
return {
|
||||
"market_report": "MKT",
|
||||
"news_report": "NEWS",
|
||||
"investment_debate_state": {"judge_decision": "RM PLAN"},
|
||||
"investment_debate_state": {"bull_history": "BULL"},
|
||||
"investment_plan": "RM PLAN",
|
||||
"trader_investment_plan": "TRADE",
|
||||
"risk_debate_state": {"judge_decision": "PM DECISION"},
|
||||
"risk_debate_state": {"neutral_history": "NEUTRAL"},
|
||||
"final_trade_decision": "PM DECISION",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def test_research_manager_prompt_states_constraint():
|
||||
"company_of_interest": "NVDA",
|
||||
"investment_debate_state": {
|
||||
"history": "h", "bull_history": "b", "bear_history": "r",
|
||||
"current_response": "", "judge_decision": "", "count": 1,
|
||||
"current_response": "", "count": 1,
|
||||
},
|
||||
})
|
||||
assert NO_EXTERNAL_TOOLS in _prompt_text(captured["prompt"])
|
||||
|
||||
@@ -292,7 +292,6 @@ def _make_rm_state():
|
||||
"bull_history": "Bull says...",
|
||||
"bear_history": "Bear says...",
|
||||
"current_response": "",
|
||||
"judge_decision": "",
|
||||
"count": 1,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user