diff --git a/tradingagents/agents/utils/memory.py b/tradingagents/agents/utils/memory.py index 2791f8d3..2ad4eb5e 100644 --- a/tradingagents/agents/utils/memory.py +++ b/tradingagents/agents/utils/memory.py @@ -52,8 +52,9 @@ class FinancialSituationMemory: def get_latest_situation(self): """Retrieve the latest entry from a situation_collection.""" - latest_entry = self.situation_collection.query(sort_by="id:descending", limit=1) - return latest_entry + collections = self.situation_collection.get() + latest_recommendation = collections["metadatas"][-1]["recommendation"] + return latest_recommendation def get_memories(self, current_situation, n_matches=1): """Find matching recommendations using OpenAI embeddings""" diff --git a/web_app/backend/main.py b/web_app/backend/main.py index 17e14257..52aa9b54 100644 --- a/web_app/backend/main.py +++ b/web_app/backend/main.py @@ -402,9 +402,6 @@ async def reflect_on_analysis(symbol: str, date: str, request: dict): if not matching_job: raise HTTPException(status_code=404, detail=f"No active job found for {symbol} on {date}") - if not hasattr(matching_job.trading_agent, 'memory') or not matching_job.trading_agent.memory: - raise HTTPException(status_code=404, detail="No memory found for this analysis") - matching_job.trading_agent.reflect_and_remember(returns_losses) try: