fix bugs on setting agent database