Skip to content

Commit

Permalink
Handling exception on agent run
Browse files Browse the repository at this point in the history
  • Loading branch information
TransformerOptimus committed Jul 14, 2023
1 parent 4d5c292 commit dc35026
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion superagi/jobs/agent_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ def execute_next_action(self, agent_execution_id):
agent_workflow_step = session.query(AgentWorkflowStep).filter(
AgentWorkflowStep.id == agent_execution.current_step_id).first()

response = spawned_agent.execute(agent_workflow_step)
try:
response = spawned_agent.execute(agent_workflow_step)
except RuntimeError as e:
# If our execution encounters an error we return and attempt to retry
logger.error("Error executing the agent:", e)
superagi.worker.execute_agent.apply_async((agent_execution_id, datetime.now()), countdown=15)
session.close()
return

if "retry" in response and response["retry"]:
superagi.worker.execute_agent.apply_async((agent_execution_id, datetime.now()), countdown=10)
Expand Down

0 comments on commit dc35026

Please sign in to comment.