feat: Implement Fast-Reject [CRITICAL ABORT] short-circuit mechanism (#131)

This commit finalizes the integration of PR #128. It implements the Fast-Reject mechanism, allowing Market and Fundamentals analysts to immediately short-circuit the execution flow to the Portfolio Manager for a SELL/AVOID decision when catastrophic conditions are detected. It also correctly updates unit tests and fixes logic vulnerabilities (checking for None) and broken tests.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com>
This commit is contained in:
ahmet guzererler 2026-03-27 11:19:50 +01:00 committed by GitHub
parent 9d2c1d296c
commit 1217b7533a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -17,8 +17,8 @@ def create_portfolio_manager(llm, memory):
# Check for critical abort in market_report or fundamentals_report
is_critical_abort = (
"[CRITICAL ABORT]" in market_research_report or
"[CRITICAL ABORT]" in fundamentals_report
(market_research_report and "[CRITICAL ABORT]" in market_research_report)
or (fundamentals_report and "[CRITICAL ABORT]" in fundamentals_report)
)
# Build current situation with all reports
@ -35,8 +35,14 @@ def create_portfolio_manager(llm, memory):
# Build prompt based on whether this is a critical abort scenario
if is_critical_abort:
# Critical abort: Use the aborting analyst's report and recommend SELL/AVOID
abort_report = market_research_report if "[CRITICAL ABORT]" in market_research_report else fundamentals_report
abort_report = (
market_research_report
if (
market_research_report
and "[CRITICAL ABORT]" in market_research_report
)
else fundamentals_report
)
prompt = f"""As the Portfolio Manager, you have received a critical abort signal from an early analyst. This indicates catastrophic conditions (bankruptcy, SEC delisting, etc.) that require immediate action.
{instrument_context}

View File

@ -13,11 +13,11 @@ class ConditionalLogic:
def _check_critical_abort(self, state: AgentState, report_field: str) -> bool:
"""Check if a report contains [CRITICAL ABORT] trigger.
Args:
state: The current agent state
report_field: The field name to check (e.g., 'market_report', 'fundamentals_report')
Returns:
True if [CRITICAL ABORT] is found in the report, False otherwise
"""