 In spring 618, Yuwen Huaji and Yuwen Zhiji, along with a number of high-level officers in Emperor Yang's elite Xiaoguo Army (驍果), were plotting a coup, but they, fearing that Yuwen Shiji, as Emperor Yang's son-in-law, would reveal the plot, did not inform Yuwen Shiji their plan.They soon launched the coup and killed Emperor Yang, declaring Emperor Yang's nephew Yang Hao the Prince of Qin emperor.Yuwen Huaji retained power as regent, and he made Yuwen Shiji "Neishi Ling" (內史令), the head of the legislative bureau of the government.