The default distributed address assignment mechanism (DAAM) of ZigBee protocol exits orphan problem without a good solution. This paper presents a mechanism called agent based address assignment mechanism (ABAAM) which can effectively reduce the orphan problem caused by the network preset parameters and nodes position. When one node cannot join the network, it selects one route node in the neighbor table as an agent and joins the network; the tree routing protocol is also improved to be compatible with the current allocation algorithm. Theoretical analysis and simulation show that the proposed algorithm has a better performance in the success rate than the default DAAM algorithm.