In 802. Liu was transferred to be a registrar (zhubu) in Weinan (in Shaanxi). The following year, on the recommendation of an official in the Imperial Censorate called Li Wen, Liu was transferred to the post of investigating censor. At that time, the essayist and poet Han Yu was already also working as an investigating censor, with Liu Zongyuan shortly to join him. These three literary giants of the middle Tang period became friends and were to remain in close contact for the rest of their lives.