What is the specific foreign policy that ultimately created the conditions for a massive rebellion against Xuanzong?
There were many prominent women at court during and after Wu's reign, including Shangguan Wan'er (664–710), a poet, writer, and trusted official in charge of Wu's private office. In 706 the wife of Emperor Zhongzong of Tang, Empress Wei (d. 710), persuaded her husband to staff government offices with his sister and her daughters, and in 709 requested that he grant women the right to bequeath hereditary privileges to their sons (which before was a male right only). Empress Wei eventually poisoned Zhongzong, whereupon she placed his fifteen-year-old son upon the throne in 710. Two weeks later, Li Longji (the later Emperor Xuanzong) entered the palace with a few followers and slew Empress Wei and her faction. He then installed his father Emperor Ruizong (r. 710–712) on the throne. Just as Emperor Zhongzong was dominated by Empress Wei, so too was Ruizong dominated by Princess Taiping. This was finally ended when Princess Taiping's coup failed in 712 (she later hanged herself in 713) and Emperor Ruizong abdicated to Emperor Xuanzong.
During the 44-year reign of Emperor Xuanzong, the Tang dynasty reached its height, a golden age with low economic inflation and a toned down lifestyle for the imperial court. Seen as a progressive and benevolent ruler, Xuanzong even abolished the death penalty in the year 747; all executions had to be approved beforehand by the emperor himself (these were relatively few, considering that there were only 24 executions in the year 730). Xuanzong bowed to the consensus of his ministers on policy decisions and made efforts to staff government ministries fairly with different political factions. His staunch Confucian chancellor Zhang Jiuling (673–740) worked to reduce deflation and increase the money supply by upholding the use of private coinage, while his aristocratic and technocratic successor Li Linfu (d. 753) favored government monopoly over the issuance of coinage. After 737 most of Xuanzong's confidence rested in his long-standing chancellor Li Linfu, who championed a more aggressive foreign policy employing non-Chinese generals. This policy ultimately created the conditions for a massive rebellion against Xuanzong.
employing non-Chinese generals