In 740, Emperor Xuanzong, impressed at the military accomplishments of the general Gai Jiayun (), the military governor of Hexi (河西, headquartered in modern Wuwei, Gansu) and Longyou (隴右, headquartered in modern Haidong Prefecture, Qinghai) Circuits, summoned him to the capital to reward him and commissioned him to plan an attack on Tufan. Gai, happy about the imperial favor, lingered in Chang'an and did not immediately depart. Pei submitted a petition, pointing out that while Gai was brave, he was becoming arrogant and unattentive in light of imperial favors. He suggested that Gai's commission be cancelled, or, in the least, that Emperor Xuanzong order Gai to immediately return to his command. Emperor Xuanzong did the latter. Later, as Pei predicted, Gai was unable to prevail over Tufan.