Added the function to consolidate agents.