Prince of Dai
In 618, after news arrived at Chang'an (which Li Yuan had taken in winter 617 and where he declared Emperor Yang's grandson Yang You the Prince of Dai emperor (as Emperor Gong)) that Emperor Yang had been killed in a coup at Jiangdu (江都, in modern Yangzhou, Jiangsu), led by the general Yuwen Huaji, Li Yuan had Yang You yield the throne to him, establishing the Tang dynasty as its Emperor Gaozu. He created Li Shimin, the Prince of Qin. Fang continued to serve on Li Shimin's staff.