agent: Adding locking support to KV store