Demand response (DR) is a recent effort to improve the efficiency of the electricity market and the stability of the power system. A successful implementation relies on both appropriate policy design and enabling technology. This paper presents a multiagent system to evaluate optimal residential DR implementation in a distribution network, in which the main stakeholders are modeled by heterogeneous home agents (HAs) and a retailer agent (RA). The HA is able to predict and control electricity load demand. A real-time price prediction model is developed for the HA and the RA. The optimal control of electricity consumption is formulated into a convex programming problem to minimize electricity payment and waiting time under real-time pricing. Simulation results show that the peak-to-average power ratio and electricity payments are significantly reduced using the proposed algorithms. The HA, with the proposed optimal control algorithms, can be embedded into a home energy management system to make intelligent decisions on behalf of homeowners responding to DR policies. The proposed agent system can be utilized to evaluate various strategies and emerging technologies that enable the implementation of DR.