Skip to content

Commit

Permalink
Fixes for webhooks (#1181)
Browse files Browse the repository at this point in the history

* fixes for webhooks

---------

Co-authored-by: namansleeps <[email protected]>
Co-authored-by: Fluder-Paradyne <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2023
1 parent e4e7d2c commit 52932fd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions superagi/controllers/agent_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def create_agent_execution(agent_execution: AgentExecutionIn,
iteration_step_id = IterationWorkflow.fetch_trigger_step_id(db.session,
start_step.action_reference_id).id if start_step.action_type == "ITERATION_WORKFLOW" else -1

db_agent_execution = AgentExecution(status="RUNNING", last_execution_time=datetime.now(),
db_agent_execution = AgentExecution(status="CREATED", last_execution_time=datetime.now(),
agent_id=agent_execution.agent_id, name=agent_execution.name, num_of_calls=0,
num_of_tokens=0,
current_agent_step_id=start_step.id,
iteration_workflow_step_id=iteration_step_id)

agent_execution_configs = {
"goal": agent_execution.goal,
"instruction": agent_execution.instruction
Expand All @@ -119,6 +119,11 @@ def create_agent_execution(agent_execution: AgentExecutionIn,
db.session.add(db_agent_execution)
db.session.commit()
db.session.flush()

#update status from CREATED to RUNNING
db_agent_execution.status = "RUNNING"
db.session.commit()

AgentExecutionConfiguration.add_or_update_agent_execution_config(session=db.session, execution=db_agent_execution,
agent_execution_configs=agent_execution_configs)

Expand Down Expand Up @@ -171,7 +176,7 @@ def create_agent_run(agent_execution: AgentRunIn, Authorize: AuthJWT = Depends(c
iteration_step_id = IterationWorkflow.fetch_trigger_step_id(db.session,
start_step.action_reference_id).id if start_step.action_type == "ITERATION_WORKFLOW" else -1

db_agent_execution = AgentExecution(status="RUNNING", last_execution_time=datetime.now(),
db_agent_execution = AgentExecution(status="CREATED", last_execution_time=datetime.now(),
agent_id=agent_execution.agent_id, name=agent_execution.name, num_of_calls=0,
num_of_tokens=0,
current_agent_step_id=start_step.id,
Expand All @@ -195,6 +200,10 @@ def create_agent_run(agent_execution: AgentRunIn, Authorize: AuthJWT = Depends(c
db.session.add(db_agent_execution)
db.session.commit()
db.session.flush()

#update status from CREATED to RUNNING
db_agent_execution.status = "RUNNING"
db.session.commit()

AgentExecutionConfiguration.add_or_update_agent_execution_config(session = db.session, execution = db_agent_execution,
agent_execution_configs = agent_execution_configs)
Expand Down

0 comments on commit 52932fd

Please sign in to comment.