diff --git a/core/agents/tech_lead.py b/core/agents/tech_lead.py index a6dba0d8..fe4d4975 100644 --- a/core/agents/tech_lead.py +++ b/core/agents/tech_lead.py @@ -251,7 +251,7 @@ class TechLead(RelevantFilesMixin, BaseAgent): self.next_state.flag_tasks_as_modified() await self.ui.send_epics_and_tasks( - self.next_state.current_epic.get("sub_epics", []), + self.next_state.epics[-1].get("sub_epics", []), self.next_state.tasks, ) diff --git a/core/state/state_manager.py b/core/state/state_manager.py index ad713876..e19427cf 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -362,9 +362,9 @@ class StateManager: # Flag tasks as modified so SQLAlchemy knows to save the changes state.flag_tasks_as_modified() - except ValueError: - # Current task not found in tasks list - this shouldn't happen but handle gracefully - log.warning("Current task not found in tasks list, skipping log trimming") + except Exception as e: + # Handle any error during log trimming gracefully + log.warning(f"Error during log trimming: {e}, skipping log trimming") pass self.current_session = session diff --git a/core/utils/text.py b/core/utils/text.py index e4c5ccb8..e70a0d18 100644 --- a/core/utils/text.py +++ b/core/utils/text.py @@ -13,21 +13,30 @@ def trim_logs(logs: str) -> str: :param logs: Log text to trim :return: Trimmed log text with the marker phrase removed """ - if not logs: - return "" + try: + if not logs: + return "" - # Define marker phrases - markers = ["Here are the backend logs", "Here are the frontend logs"] + # Ensure we have a string + if not isinstance(logs, str): + logs = str(logs) - # Find the first occurrence of any marker - index = float("inf") - for marker in markers: - pos = logs.find(marker) - if pos != -1 and pos < index: - index = pos + # Define marker phrases + markers = ["Here are the backend logs", "Here are the frontend logs"] - # If a marker was found, trim the string - if index != float("inf"): - return logs[:index] + # Find the first occurrence of any marker + index = float("inf") + for marker in markers: + pos = logs.find(marker) + if pos != -1 and pos < index: + index = pos - return logs + # If a marker was found, trim the string + if index != float("inf"): + return logs[:index] + + return logs + + except Exception: + # If anything goes wrong, return the original input as string or empty string + return str(logs) if logs is not None else ""