From 486dec1710d5b00c76036d6213dd96bfc2de51c2 Mon Sep 17 00:00:00 2001 From: Yijia-Xiao Date: Thu, 17 Sep 2026 05:00:08 +0000 Subject: [PATCH] fix(agents): state the output shape in the decision prompts - the field list lived only in the schema, which a provider without structured output never sees - the trader maps the five-tier recommendation onto its three actions --- tradingagents/agents/managers/portfolio_manager.py | 8 ++++++++ tradingagents/agents/managers/research_manager.py | 8 ++++++++ tradingagents/agents/trader/trader.py | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tradingagents/agents/managers/portfolio_manager.py b/tradingagents/agents/managers/portfolio_manager.py index ca55bdbcd..c85039236 100644 --- a/tradingagents/agents/managers/portfolio_manager.py +++ b/tradingagents/agents/managers/portfolio_manager.py @@ -68,6 +68,14 @@ def create_portfolio_manager(llm): Ground every conclusion in specific evidence from the analysts. The risk debate always contains conflicting stances; deciding which is stronger is the job, so conflict alone is not a reason to Hold. Commit to the stronger case, sized by how decisively it wins. Choose Hold only when the evidence is still balanced after that weighing, or too thin to support a call; do not force a direction to appear decisive. Weigh the analysts on their merits, independent of speaking order. +## Output + +Write these sections, in this order, starting with the rating on its own line: + +- **Rating**: exactly one of Buy / Overweight / Hold / Underweight / Sell +- **Executive Summary**: the call and how to act on it +- **Investment Thesis**: the evidence that decided it, and what would change it + {NO_EXTERNAL_TOOLS}{get_language_instruction()}""" final_trade_decision = invoke_structured_or_freetext( diff --git a/tradingagents/agents/managers/research_manager.py b/tradingagents/agents/managers/research_manager.py index ed77b88d3..0ffd2f4a2 100644 --- a/tradingagents/agents/managers/research_manager.py +++ b/tradingagents/agents/managers/research_manager.py @@ -43,6 +43,14 @@ The debate always contains conflicting arguments; deciding which side is stronge **Debate History:** {history} +## Output + +Write these sections, in this order, starting with the recommendation on its own line: + +- **Recommendation**: exactly one of Buy / Overweight / Hold / Underweight / Sell +- **Rationale**: which arguments decided it +- **Strategic Actions**: concrete steps for the trader, sized against a standard allocation + {NO_EXTERNAL_TOOLS}""" + get_language_instruction() investment_plan = invoke_structured_or_freetext( diff --git a/tradingagents/agents/trader/trader.py b/tradingagents/agents/trader/trader.py index b7d91754a..a82ee4bab 100644 --- a/tradingagents/agents/trader/trader.py +++ b/tradingagents/agents/trader/trader.py @@ -71,7 +71,15 @@ def create_trader(llm): f"{report_section}" f"{portfolio_context}\n\n" f"Proposed Investment Plan:\n{investment_plan}\n\n" - f"Make an informed, strategic trading decision." + "Make an informed, strategic trading decision.\n\n" + "## Output\n\n" + "Write these sections, in this order, starting with the action " + "on its own line:\n\n" + "- **Action**: exactly one of Buy / Hold / Sell. A research " + "recommendation of Overweight is a Buy and Underweight is a Sell, " + "sized by how strong the case is; conflict alone is not a Hold.\n" + "- **Reasoning**: why, against the plan and the price structure\n" + "- **Entry Price**, **Stop Loss**, **Position Sizing**: when you can state them" ), }, ]