fix(agent): ensure active run key is deleted upon stopping agent run

This commit is contained in:
sharath 2025-07-05 17:35:41 +00:00
parent 54827b6582
commit a022694e4a
No known key found for this signature in database
2 changed files with 4 additions and 0 deletions

View File

@ -202,6 +202,8 @@ async def stop_agent_run(agent_run_id: str, error_message: Optional[str] = None)
await update_agent_run_status( await update_agent_run_status(
client, agent_run_id, final_status, error=error_message client, agent_run_id, final_status, error=error_message
) )
instance_key = f"active_run:{instance_id}:{agent_run_id}"
await redis.client.delete(instance_key)
logger.info(f"Successfully initiated stop process for agent run: {agent_run_id}") logger.info(f"Successfully initiated stop process for agent run: {agent_run_id}")
# async def restore_running_agent_runs(): # async def restore_running_agent_runs():

View File

@ -227,6 +227,8 @@ async def run_agent_background(
) )
finally: finally:
instance_key = f"active_run:{instance_id}:{agent_run_id}"
await redis.client.delete(instance_key)
logger.info( logger.info(
f"Agent run completed for: {agent_run_id} (Instance: {instance_id}) with final status: {final_status}" f"Agent run completed for: {agent_run_id} (Instance: {instance_id}) with final status: {final_status}"
) )