Kong Wei

[4] He passed the imperial examinations in the Jinshi class in 859, during the reign of Emperor Xuānzong, and therefore served as a copyeditor (校書郎, Xiaoshu Lang) at the Palace Library.

[4][11] The chancellor Xu Shang then recommended that he be made a scholar at Jixian Hall (集賢院) as well as Kaogong Yuanwailang (考功員外郎), a low-level official at the minister of civil service affairs (吏部, Lìbu, note different tone than the ministry of rites).

He then returned to the imperial government as Yousi Yuanwailang (右司員外郎), a low-level official under one of the secretaries general of the executive bureau (尚書省, Shangshu Sheng).

This offended those who made requests of him, and he was given the largely powerless post of minister of worship (太常卿, Taichang Qing).

[4] In late 880, the major agrarian rebel Huang Chao attacked Chang'an, and Emperor Xizong fled to Chengdu.

[14] Kong followed Emperor Xizong there, and was made the minister of justice (刑部尚書, Xingbu Shangshu) and acting director of finances.

[4][15] Late that year, the powerful eunuch Tian Lingzi provoked the warlord Wang Chongrong the military governor of Hezhong by ordering Wang transferred, and Wang and his ally Li Keyong the military governor of Hedong Circuit (河東, headquartered in modern Taiyuan, Shanxi) reacted by engaging forces under Tian and Tian's allies Zhu Mei the military governor of Jingnan Circuit (靜難, headquartered in modern Xianyang, Shaanxi) and Li Changfu the military governor of Fengxiang Circuit (鳳翔, headquartered in modern Baoji, Shaanxi).

As a result, Tian escorted Emperor Xizong to flee to Fengxiang, and then to Xingyuan (興元, in modern Hanzhong, Shaanxi).

[15] After Kong Wei's arrival in Xingyuan, Emperor Xizong made both him and Du Rangneng deputy ministers of defense, as well as chancellors, with the designation Tong Zhongshu Menxia Pingzhangshi (同中書門下平章事).

[15] After Emperor Xizong subsequently was able to return to Chang'an after Zhu Mei was killed by his own officer Wang Xingyu (who was promised that if he did so, he could succeed Zhu as military governor of Jingnan), Kong was given the additional post of Zuo Pushe (左僕射, one of the heads of the executive bureau), and was given an iron certificate, guaranteeing that he would not be put to death.

[17] Kong's and Zhang's drive to reduce the eunuchs' and the warlords' power, however, caused them to make an ill-advised recommendation to Emperor Zhaozong in 890, however.

However, Kong and Zhang, believing that this was the time to assert imperial authority over warlords and to try to use a victory to then overpower the eunuchs, were insistent on a campaign against Li Keyong, citing Li Keyong's participation in the campaign that forced Emperor Xizong to flee the capital a second time.

[17] As Zhang was departing for his exile, however, he fled instead to Han Jian, who was then the military governor of Zhenguo Circuit (鎮國, headquartered at Hua Prefecture), and wrote Zhu Quanzhong, asking for him to intercede.

In fear, Emperor Zhaozong, under the protection of the imperial guard general Li Yun (李筠), fled toward the Qinling Mountains.