Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed api_bug #1081

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions superagi/controllers/api/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def update_agent(agent_id: int, agent_with_config: AgentConfigUpdateExtInput,api
if project.organisation_id!=organisation.id:
raise HTTPException(status_code=404, detail="Agent not found")

db_execution=AgentExecution.get_execution_by_agent_id_and_status(db.session, agent_id, "RUNNING")
if db_execution is not None:
raise HTTPException(status_code=409, detail="Agent is already running,please pause and then update")
# db_execution=AgentExecution.get_execution_by_agent_id_and_status(db.session, agent_id, "RUNNING")
# if db_execution is not None:
# raise HTTPException(status_code=409, detail="Agent is already running,please pause and then update")

db_schedule=AgentSchedule.find_by_agent_id(db.session, agent_id)
if db_schedule is not None:
Expand Down Expand Up @@ -295,9 +295,11 @@ def resume_agent_runs(agent_id:int,execution_state_change_input:ExecutionStateCh
db_execution_arr=AgentExecution.get_all_executions_by_status_and_agent_id(db.session, agent.id, execution_state_change_input, "PAUSED")
for ind_execution in db_execution_arr:
ind_execution.status="RUNNING"
execute_agent.delay(ind_execution.id, datetime.now())

db.session.commit()
db.session.flush()

return {
"result":"success"
}
Expand Down
8 changes: 4 additions & 4 deletions superagi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
}
app.conf.beat_schedule = beat_schedule

@event.listens_for(AgentExecution.status, "set")
def agent_status_change(target, val,old_val,initiator):
if get_config("IN_TESTING",False):
webhook_callback.delay(target.id,val,old_val)
# @event.listens_for(AgentExecution.status, "set")
# def agent_status_change(target, val,old_val,initiator):
# if not get_config("IN_TESTING",False):
# webhook_callback.delay(target.id,val,old_val)


@app.task(name="initialize-schedule-agent", autoretry_for=(Exception,), retry_backoff=2, max_retries=5)
Expand Down