President Trump made small talk with the Irish prime minister as they sat in the Oval Office in mid-March, accompanied by a handful of senior American and Irish officials. Trump, who wore a green tie and filled his jacket pocket with a clump of shamrock to honor the Irish leader's annual St. Patrick's Day visit, turned with a half-smile to his hawkish national security adviser John Bolton, according to two sources who were in the room.

"John," Trump asked, "Is Ireland one of those countries you want to invade?"

Behind the scenes: The joke captured how Trump often privately interacts with Bolton, even occasionally in front of foreign heads of state. "John has never seen a war he doesn't like," Trump said in a recent Oval Office meeting, according to a source with direct knowledge.

Trump often privately ribs Bolton about his public persona, according to sources who've been in Situation Room meetings with them. (Trump teases most of his top advisers and officials in different ways. For example, during discussions of trade with China, Trump has needled Treasury Secretary Steven Mnuchin in front of other senior officials: "Steve, you're so weak. You're so weak. You didn't used to be this way in business. You're so weak now.")

In a SitRoom meeting last year, Trump's national security team was going around the table discussing a topic that was nuanced and had no relation to major military action. A source in the room said that as the conversation got to Bolton, Trump joked: "Ok, John, let me guess, you want to nuke them all?" People in the room "died laughing," the source said.

Between the lines: That's not to say that Trump's view of Bolton is rose-colored. People close to Bolton have recently worried about his job security. Yet while Bolton can rub Trump the wrong way — a well-documented dynamic — and while internal and external Bolton critics often complain to Trump that Bolton will drag him into an unwanted war, Trump still defends his national security adviser in private conversations with critics.

"He gets quite touchy when you bring it up," said a person who has criticized the national security adviser to the president. "He doesn't want anyone to believe he's anybody's pawn."

Trump's Bolton Doctrine: Trump has a strongly held theory of Bolton's value, according to senior administration officials and advisers to the president, including people who have privately recommended to Trump that he fire Bolton. Seven sources who have discussed Bolton with Trump told me the president says having Bolton on his team improves his bargaining position and gives him a psychological advantage over foes like Iran and North Korea.

"Trump thinks that Bolton is a key part of his negotiating strategy," said the same person who described Trump as "touchy" about Bolton. "He thinks that Bolton's bellicosity and eagerness to kill people is a bargaining chip when he's sitting down with foreign leaders. Bolton can be the bad cop and Trump can be the good cop. Trump believes this to his core."

A former senior administration official who remains close to Trump said Bolton's presence on the team "makes other people know that there is going to be that type of voice in the room."

Trump occasionally flips the good cop, bad cop script with his national security adviser. In the expanded bilateral meeting with the Dutch prime minister on Thursday in the Cabinet Room, Trump was criticizing European nations, including the Dutch, for not spending enough to meet their NATO obligations, according to a source familiar with the meeting. At one point, after Trump gave this criticism, he turned to Bolton, who was sitting to his right and said, "But, John, you love NATO right?"

Bolton gave a very brief defense of NATO. Then Trump started drilling down again on his dissatisfactions, the source said.

Inside the room: A former senior administration official who has watched Trump and Bolton interact said that Trump thinks Bolton is "prepared and very smart," even though he often disagrees with him and becomes exasperated by some of his advice.

Another thing Bolton did early on, which earned Trump's respect, was standing up to former Defense Secretary James Mattis, according to sources with direct knowledge.

Bolton's predecessor, Gen. H.R. McMaster, had been deferential to Mattis and called him "Sir" or "Secretary Mattis" — conscious of his 3 stars to Mattis' 4. In one of Bolton's early SitRoom meetings with Mattis, he set a new tone, according to a source who was in the room.

Mattis was giving a history lecture and Bolton interrupted him, according to the source who witnessed the exchange and recalls it vividly. "Jim," Bolton said tapping the table, "let me just stop you there. In 90 seconds you have already been wrong about three things." (Trump was not in the room for that exchange, the source said, but the president caught on that he now had a national security adviser who would stand up to Mattis.)

Why this matters: Several of Bolton's allies outside the administration have been jittery about his standing with the president. One Bolton ally told me he worried that because Bolton doesn't play nice with colleagues or play golf with Trump, he doesn't have the personal chemistry with Trump or the broad goodwill with his administration colleagues to protect him when he's "shaky" with the president.

"Bolton doesn't help himself," said a senior White House official. "He runs as hard as he can and doesn't look to do things nicely or diplomatically."

"When he gets serious about something that he really wants, he can push too hard and too fast without involving everybody, and that makes people really mad," said a former senior White House official.

Trump tells confidants who are concerned about Bolton that they shouldn't worry about his national security adviser dragging him into a war. Early on in Bolton's tenure, Trump told confidants that "Bolton is OK, he wants to start 3 wars a day, but I have him on a leash," according to a former senior administration official.

"He believes that because he, Donald Trump, doesn't want war, then there won't be war," said another person who has discussed Bolton with Trump. This person, like others in Trump's orbit, said they worry Trump's inexperience in government leads him to underestimate how Bolton's seemingly inconsequential decisions could increase the likelihood of a war with Iran.

A source who discussed Venezuela with Trump said that while the president agreed with Bolton on the need for regime change, the president grew irritated at Bolton's aggression. Trump told confidants that Bolton was going too far and that some of the people around him were overly confident that the Venezuelan opposition could remove dictator Nicolás Maduro.

Another source, a former senior administration official, recalls Trump saying that people he was listening to were too optimistic about the Venezuelan opposition toppling Maduro. "I distinctly remember [Trump] saying, 'I've seen these type of people, people underestimate him [Maduro]. He's not just going to give up and walk away.'"

The bottom line: It's true that Trump has been frustrated with Bolton — sometimes deeply so. But even some who most want Bolton gone grudgingly concede that the hawk who Trump once said would "take on the whole world at one time" may survive for a while yet.