During Emperor Taizong's reign
In 626, Li Shimin ambushed Li Jiancheng and Li Yuanji at Xuanwu Gate and killed them. He then effectively forced Emperor Gaozu to first create him crown prince and then yield the throne to him (as Emperor Taizong). Emperor Taizong recalled Du Yan from exile, made him the imperial censor, and created him the Duke of Anji. Emperor Taizong made Du in charge of the creation ceremony for his son and crown prince Li Chengqian, and in 627 made him the minister of civil service affairs. He also bestowed Du with the additional designation of Canyu Chaozheng (參豫朝政) -- a de facto chancellor designation. It was said that in these capacities, Du recommended more than 40 people to be imperial officials, and many of them were later known for good service.
There was a famous exchange between Emperor Taizong and Du involving Du's recommendation of a minor imperial official, Di Daohuai (邸道懷). As the Old Book of Tang recorded, this was the conversation:
Emperor Taizong asked Du, "How are Di's abilities?" Du responded, "During Sui days, Di served as an assistant official at the ministry of civil service affairs, and he was known for his integrity. When Emperor Yang was going to visit Jiangdu [(江都, in modern Yangzhou, Jiangsu), where Emperor Yang eventually died] and made up his mind, the high-level officials were all obedient to Emperor Yang, but Di, despite his low position, was insistent against it. I personally saw that myself. Emperor Taizong asked, "What did you advise Emperor Yang?" Du responded, "I told him to go." Emperor Taizong said, "Part of your responsibility in serving the emperor was to be honest without hiding anything. You praise Di, so why did you not make the same insistent advice?" Du responded, "At that time, I was not in an important post. I also knew that such advice would not be accepted, and it would not be of benefit for me to die." Emperor Taizong responded, "Confucius said that a son who always obeyed his father was not actually a filially pious son. Therefore a father needs to have a son who would give adverse advice, and a state needs to have officials who would give adverse advice. If you believe that Emperor Yang was a tyrant, why continue to serve him? If you accepted his salary, you had the responsibility to give good advice to him." ... He then smiled and said to Du, "When you, Lord, were serving under Sui, you were at a low post and maybe you had justification not to speak up. You were highly honored in Wang Shichong's administration. Why did you not speak up then?" Du responded, "I did. It was just that he did not listen to me." Emperor Taizong responded, "If Wang was virtuous and did what was good, then he would not have been destroyed. If he was a tyrant and resisted adverse advice, how could you have avoided disaster?" Du could not respond. Emperor Taizong then said, "Now you are highly honored. Are you willing to speak up?" Du responded, "I am willing to die. Further, when Baili Xi was at Yu, Yu was destroyed, but when he was at Qin, Qin became a major power. That is whom I secretly compare myself to." Emperor Taizong laughed.
At that time, Du was in multiple posts, but was not known for being honest. He was also discordant with Zhangsun Wuji, and his reputation suffered. When he later became ill, Emperor Taizong personally visited him and bestowed a gift of silk on him. He died in November 628.