In an extraordinary interview with The New York Times, President Trump was inappropriately critical of Attorney General Jeff Sessions. It was almost an invitation for Sessions to resign. He should not.

There are many good people serving in this administration, under difficult circumstances. The circumstances are not difficult because of a foreign threat, economic calamity or effective political opposition, but because of the conduct, temperament and character of the president.

Nonetheless, it is vital that the good people who function as the anchors of the Trump administration stay in place and serve for as long as they can. Without them, things would be worse. The American political system could become more fragile and our country could be in peril.

Everyone working in an administration always wants the president’s confidence. But if what you have to do to maintain that confidence is inconsistent with what would best serve US interests, you should keep doing your job despite knowing the president is dissatisfied with your work.

It’s easy to see how people such as National Security Adviser H.R. McMaster and Defense Secretary Jim Mattis are pivotal to ensuring the worst doesn’t happen. Their presence guarantees that America’s weapons arsenal is safe and our defenses are at the ready. But there are also scores of other White House staff members and executive-agency leaders who are vital to keeping some semblance of a rational functioning of the bureaucracy.

Jeff Sessions is one such person. He knows what to do as attorney general and what is best for the country — even if the president does not. We owe Sessions and others more because they are serving in the Trump administration, not less.

Trump is erratic and too often unappreciative of those serving in his administration. He is unnecessarily dismissive of their contributions and peddles unsubstantiated mistruths that degrade morale throughout the White House, his administration and the entire federal government.

Given the president’s predilection to throwing anyone and everyone around him under the bus when the times are tough, I worry that there could be a wholesale exodus from the administration after the midterm elections (if not before) and an inability to refill vital posts with good people.

So, to Sessions and others who are serving in the Trump administration, remember that your commitment may not always be to the man, Donald Trump, but to the institution that you serve and to the presidency itself. Hang in there. Don’t quit.

And for those of you thinking about accepting a job in the administration but have doubts after reading stories such as the one in The New York Times, ignore them. Take that job and do your best. A lot of people will be thankful you did. And a lot of people will be pulling for you.

Even if the president fails to realize that he needs good people around him, the fact is, America needs good people. Perhaps that’s true now more than ever and becoming more true as conditions deteriorate.

The honorable thing to do at a time like this is not quit, but stay and try to keep the worst from happening.

Ed Rogers is a political consultant and a veteran of the Ronald Reagan and George H.W. Bush White Houses. Special To The Washington Post.