mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-19 19:25:24 +03:00
fix(graph): give the shared debate/risk routers a complete path_map
- should_continue_debate (2 edges) and should_continue_risk_analysis (3 edges) each returned more targets than any one edge mapped; a fall-through under prompt/i18n/refactor drift crashed LangGraph mid-run - share a complete DEBATE_PATH_MAP / RISK_ANALYSIS_PATH_MAP across every edge #1088
This commit is contained in:
@@ -25,6 +25,22 @@ from tradingagents.agents.utils.agent_states import AgentState
|
||||
from .analyst_execution import build_analyst_execution_plan
|
||||
from .conditional_logic import ConditionalLogic
|
||||
|
||||
# Every target a shared conditional router can return. Each edge driven by the
|
||||
# router maps all of them, so a fall-through return (e.g. under prompt/i18n/
|
||||
# refactor drift in the speaker labels) can never hit a missing path_map entry
|
||||
# and crash LangGraph mid-run (#1088).
|
||||
DEBATE_PATH_MAP = {
|
||||
"Bull Researcher": "Bull Researcher",
|
||||
"Bear Researcher": "Bear Researcher",
|
||||
"Research Manager": "Research Manager",
|
||||
}
|
||||
RISK_ANALYSIS_PATH_MAP = {
|
||||
"Aggressive Analyst": "Aggressive Analyst",
|
||||
"Conservative Analyst": "Conservative Analyst",
|
||||
"Neutral Analyst": "Neutral Analyst",
|
||||
"Portfolio Manager": "Portfolio Manager",
|
||||
}
|
||||
|
||||
|
||||
class GraphSetup:
|
||||
"""Handles the setup and configuration of the agent graph."""
|
||||
@@ -118,49 +134,22 @@ class GraphSetup:
|
||||
else:
|
||||
workflow.add_edge(current_clear, "Bull Researcher")
|
||||
|
||||
# Add remaining edges
|
||||
workflow.add_conditional_edges(
|
||||
"Bull Researcher",
|
||||
self.conditional_logic.should_continue_debate,
|
||||
{
|
||||
"Bear Researcher": "Bear Researcher",
|
||||
"Research Manager": "Research Manager",
|
||||
},
|
||||
)
|
||||
workflow.add_conditional_edges(
|
||||
"Bear Researcher",
|
||||
self.conditional_logic.should_continue_debate,
|
||||
{
|
||||
"Bull Researcher": "Bull Researcher",
|
||||
"Research Manager": "Research Manager",
|
||||
},
|
||||
)
|
||||
# Both research-debate edges share the complete DEBATE_PATH_MAP (#1088).
|
||||
for debate_node in ("Bull Researcher", "Bear Researcher"):
|
||||
workflow.add_conditional_edges(
|
||||
debate_node,
|
||||
self.conditional_logic.should_continue_debate,
|
||||
DEBATE_PATH_MAP,
|
||||
)
|
||||
workflow.add_edge("Research Manager", "Trader")
|
||||
workflow.add_edge("Trader", "Aggressive Analyst")
|
||||
workflow.add_conditional_edges(
|
||||
"Aggressive Analyst",
|
||||
self.conditional_logic.should_continue_risk_analysis,
|
||||
{
|
||||
"Conservative Analyst": "Conservative Analyst",
|
||||
"Portfolio Manager": "Portfolio Manager",
|
||||
},
|
||||
)
|
||||
workflow.add_conditional_edges(
|
||||
"Conservative Analyst",
|
||||
self.conditional_logic.should_continue_risk_analysis,
|
||||
{
|
||||
"Neutral Analyst": "Neutral Analyst",
|
||||
"Portfolio Manager": "Portfolio Manager",
|
||||
},
|
||||
)
|
||||
workflow.add_conditional_edges(
|
||||
"Neutral Analyst",
|
||||
self.conditional_logic.should_continue_risk_analysis,
|
||||
{
|
||||
"Aggressive Analyst": "Aggressive Analyst",
|
||||
"Portfolio Manager": "Portfolio Manager",
|
||||
},
|
||||
)
|
||||
# All three risk edges share the complete RISK_ANALYSIS_PATH_MAP (#1088).
|
||||
for risk_node in ("Aggressive Analyst", "Conservative Analyst", "Neutral Analyst"):
|
||||
workflow.add_conditional_edges(
|
||||
risk_node,
|
||||
self.conditional_logic.should_continue_risk_analysis,
|
||||
RISK_ANALYSIS_PATH_MAP,
|
||||
)
|
||||
|
||||
workflow.add_edge("Portfolio Manager", END)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user