# TradingAgents/graph/propagation.py from typing import Any from tradingagents.agents.libs.agent_states import ( InvestDebateState, RiskDebateState, ) class Propagator: """Handles state initialization and propagation through the graph.""" def __init__(self, max_recur_limit=100): """Initialize with configuration parameters.""" self.max_recur_limit = max_recur_limit def create_initial_state( self, company_name: str, trade_date: str ) -> dict[str, Any]: """Create the initial state for the agent graph.""" return { "messages": [("human", company_name)], "company_of_interest": company_name, "trade_date": str(trade_date), "investment_debate_state": InvestDebateState( bull_history="", bear_history="", history="", current_response="", judge_decision="", count=0, ), "risk_debate_state": RiskDebateState( risky_history="", safe_history="", neutral_history="", history="", latest_speaker="", current_risky_response="", current_safe_response="", current_neutral_response="", judge_decision="", count=0, ), "market_report": "", "fundamentals_report": "", "sentiment_report": "", "news_report": "", } def get_graph_args(self) -> dict[str, Any]: """Get arguments for the graph invocation.""" return { "stream_mode": "values", "config": {"recursion_limit": self.max_recur_limit}, }