mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-08 12:53:50 -05:00
add extra safety try catch
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
Reference in New Issue
Block a user