The guided-missile destroyer USS Porter conducts strike operations from the Mediterranean Sea. (Ford Williams/Agence France-Presse via Getty Images)

For a reminder of how new administrations can quickly get into trouble in foreign policy, consider that Monday, April 17, marks the anniversary of the catastrophic Bay of Pigs invasion in 1961 by President John F. Kennedy. Bad things can happen to good presidents, and vice versa.

President Trump, after a mostly disastrous first two months, has had a good run these past two weeks in foreign policy. He acted decisively in Syria, gained China as a possible partner in dealing with North Korea, repaired relations with NATO and began addressing the serious tensions with Russia.

Why is Trump making better decisions now? And what could disrupt his progress toward a more coherent foreign policy?

Trump is making gains because he has assembled a competent national security team — and listens to its advice. There was a consensus among his top advisers for a quick, limited strike on a Syrian air base, and Trump took the recommendation. He didn’t amplify, augment or otherwise disrupt it with his own tweets. He allowed the process to work.

If Trump goes back to his freewheeling, tweeter-in-chief role, or if the disruptive would-be chief strategist Stephen K. Bannon regains influence, then chaos could return. But for now, Trump has bonded with his core team. And in this White House, starved for a win, nothing succeeds like success.

(Adriana Usero/The Washington Post)

Contrast the quick, relatively clean decision on the military strike in Syria with the chaotic White House discussions about the 1961 Cuba invasion. The CIA didn’t level with Kennedy about its doubts that Cuban exiles could succeed without air cover; the Pentagon resented the covert paramilitary operation; Kennedy let himself get dragged into a mistake that prefigured the 1962 Cuban missile crisis and nearly led to nuclear war.

The Bay of Pigs illustrates what happens when a policy process goes bad. Other administrations have also had bumpy starts. President George W. Bush had a messy first few years, with recurring feuds between Defense Secretary Donald H. Rumsfeld, Secretary of State Colin Powell, national security adviser Condoleezza Rice and Vice President Dick Cheney. It was only in Bush’s second term that he really got the balance right. Presidents Ronald Reagan and Bill Clinton also had ragged beginnings.

The Trump team, for now, is basking in self-congratulation. Bannon’s power is diminished and H.R. McMaster has taken over as a disciplined national security adviser. Comity reigns in part because Defense Secretary Jim Mattis and Secretary of State Rex Tillerson hammer out common positions before every meeting in the Situation Room.

Trump’s strength and weakness is his emphasis on personality politics. That was evident in his meeting with Chinese President Xi Jinping, which included nearly four hours of one-on-one conversation. Trump was bubbly at a news conference Wednesday in describing the “good chemistry” of the meeting. Such talk is the elevator music of summits, but in this case, the two do seem to have developed a mutually opportunistic bond. Xi is signaling that China’s interests are served by working with the United States to check North Korea, short of war. Will that last? We’ll see.

Trump’s North Korea strategy had a coherent rollout. First Mattis visited the region, followed by Tillerson; as tensions rose this week, the United States signaled resolve by dispatching an aircraft-carrier task force. Behind these tactical moves are some big strategic ideas about a future North Korea that wouldn’t threaten China’s interests.

The danger is over-personalizing policy. Trump likes people who make him look good (as Xi has done). But personal success can’t be the engine of statecraft.

Trump’s first two months were a case study in self-destructive actions. An example of how he undermined his team’s good ideas was a plan back in January for defusing trade and immigration tensions with Mexico. The centerpiece would have been a visit to Washington by President Enrique Peña Nieto. But Trump got defensive about criticism that he was backing away from his campaign rhetoric and unleashed an inflammatory tweet that led Peña Nieto to cancel the visit.

The Mexico flap added to the uproar and disarray of Trump’s first weeks. Trump was running at government with his head; he was behaving like a guy who gets into bar fights. Somebody (presumably Bannon) must have told him that this was a good idea. That’s how advisers lose clout.

Over the past week, Trump has adopted a different approach — more careful and consensual. Yes, it brings him closer to the foreign policy mainstream that he and Bannon derided during the campaign. But it also gives him a taste of the success he craves.

Read more from David Ignatius’s archive, follow him on Twitter or subscribe to his updates on Facebook.