diff --git a/backend/agent/api.py b/backend/agent/api.py index 2ba69c8a..c19ec37a 100644 --- a/backend/agent/api.py +++ b/backend/agent/api.py @@ -202,6 +202,8 @@ async def stop_agent_run(agent_run_id: str, error_message: Optional[str] = None) await update_agent_run_status( 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}") # async def restore_running_agent_runs(): diff --git a/backend/run_agent_background.py b/backend/run_agent_background.py index 49adac10..bc7b3c4c 100644 --- a/backend/run_agent_background.py +++ b/backend/run_agent_background.py @@ -227,6 +227,8 @@ async def run_agent_background( ) finally: + instance_key = f"active_run:{instance_id}:{agent_run_id}" + await redis.client.delete(instance_key) logger.info( f"Agent run completed for: {agent_run_id} (Instance: {instance_id}) with final status: {final_status}" )