Function to update agents' status