Refactor replication lag persistence using an Agent