Skip to content

Commit

Permalink
Add logic to handle execution attempt logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayan-Bandyopadhyay committed Sep 11, 2024
1 parent 3f7b3bc commit b788812
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion server/agent_runner/agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@ async def start_agent(
async def update_execution(
self, agent: Agent, execution: Execution, attempt: ExecutionAttempt
):
pass
# Update the execution status
if attempt.success:
execution.status = ExecutionStatus.successful
elif len(execution.attempts) == agent.num_retries:
execution.status = ExecutionStatus.failed
else:
execution.status = ExecutionStatus.running

# Add the attempt to the execution
execution.attempts.append(attempt.dict())

return execution
6 changes: 3 additions & 3 deletions server/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ async def list_agents(self, config: AppConfig) -> List[Agent]:
return [Agent(**row) for row in response.data]

async def list_executions(
self, config: AppConfig, agent_id: str
self, config: AppConfig, finic_agent_id: str
) -> List[Execution]:
response = (
self.supabase.table("execution")
.select("*")
.filter("app_id", "eq", config.app_id)
.filter("agent_id", "eq", agent_id)
.filter("finic_agent_id", "eq", finic_agent_id)
.execute()
)
return [Execution(**row) for row in response.data]
Expand All @@ -118,7 +118,7 @@ async def get_execution(
self.supabase.table("execution")
.select("*")
.filter("app_id", "eq", config.app_id)
.filter("finic_agent_id", "eq", finic_agent_id)
.filter("agent_id", "eq", finic_agent_id)
.filter("id", "eq", execution_id)
.execute()
)
Expand Down

0 comments on commit b788812

Please sign in to comment.