Skip to content

Commit

Permalink
made the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anisha1607 committed Jul 20, 2023
1 parent c697937 commit d7468f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion superagi/controllers/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ def delete_agent(agent_id: int, Authorize: AuthJWT = Depends(check_auth)):
"""

db_agent = db.session.query(Agent).filter(Agent.id == agent_id).first()
db_agent_executions = db.session.query(AgentExecution).filter(AgentExecution.agent_id == agent_id).all()
db_agent_executions = db.session.query(AgentExecution).filter(AgentExecution.agent_id == agent_id).all()
db_agent_schedule = db.session.query(AgentSchedule).filter(AgentSchedule.agent_id == agent_id, AgentSchedule.status == "SCHEDULED").first()

if not db_agent or db_agent.is_deleted:
raise HTTPException(status_code=404, detail="agent not found")
Expand All @@ -515,5 +516,9 @@ def delete_agent(agent_id: int, Authorize: AuthJWT = Depends(check_auth)):
# Updating all the RUNNING executions to TERMINATED
for db_agent_execution in db_agent_executions:
db_agent_execution.status = "TERMINATED"

if db_agent_schedule:
# Updating the schedule status to DELETED
db_agent_schedule.status = "DELETED"

db.session.commit()
2 changes: 1 addition & 1 deletion superagi/models/agent_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AgentSchedule(DBBaseModel):
expiry_date (DateTime): The date and time when the agent is scheduled to stop runs.
expiry_runs (Integer): The number of runs before the agent expires.
current_runs (Integer): Number of runs executed in that schedule.
status: state in which the schedule is, "SCHEDULED" or "STOPPED" or "COMPLETED" or "TERMINATED"
status: state in which the schedule is, "SCHEDULED" or "STOPPED" or "COMPLETED" or "TERMINATED" or "DELETED"
Methods:
__repr__: Returns a string representation of the AgentSchedule instance.
Expand Down

0 comments on commit d7468f1

Please sign in to comment.