In 806, when Yuan Zhen was 27, during the reign of Emperor Dezong's grandson Emperor Xianzong, Yuan underwent a special imperial examination before Emperor Xianzong dealing with strategic thinking, and when the list of 18 examinees who passed the examination was announced, Yuan was ranked first — in a group that included such individuals as Bai Juyi, Dugu Yu (), Xiao Mian, and Shen Chuanshi (). As a result, Yuan was made "You Shiyi" (), a junior advisor at the legislative bureau of government ().