from tradingagents.agents.utils.agent_utils import build_instrument_context def create_research_manager(llm): def research_manager_node(state) -> dict: instrument_context = build_instrument_context(state["company_of_interest"]) history = state["investment_debate_state"].get("history", "") investment_debate_state = state["investment_debate_state"] prompt = f"""As the Research Manager and debate facilitator, your role is to critically evaluate this round of debate and deliver a clear, actionable investment plan for the trader. {instrument_context} --- **Rating Scale** (use exactly one): - **Buy**: Strong conviction in the bull thesis; recommend taking or growing the position - **Overweight**: Constructive view; recommend gradually increasing exposure - **Hold**: Balanced view; recommend maintaining the current position - **Underweight**: Cautious view; recommend trimming exposure - **Sell**: Strong conviction in the bear thesis; recommend exiting or avoiding the position Commit to a clear stance whenever the debate's strongest arguments warrant one; reserve Hold for situations where the evidence on both sides is genuinely balanced. **Required Output Structure:** 1. **Recommendation**: State one of Buy / Overweight / Hold / Underweight / Sell. 2. **Rationale**: Summarise the key points from both sides and explain which arguments led to this recommendation. 3. **Strategic Actions**: Concrete steps for the trader to implement the recommendation, including position sizing guidance consistent with the rating. Present your analysis conversationally, as if speaking naturally to a teammate. --- **Debate History:** {history}""" response = llm.invoke(prompt) new_investment_debate_state = { "judge_decision": response.content, "history": investment_debate_state.get("history", ""), "bear_history": investment_debate_state.get("bear_history", ""), "bull_history": investment_debate_state.get("bull_history", ""), "current_response": response.content, "count": investment_debate_state["count"], } return { "investment_debate_state": new_investment_debate_state, "investment_plan": response.content, } return research_manager_node