President Obama in the Pentagon briefing room on Monday. (Olivier Douliery / Pool/European Pressphoto Agency)

To Republican presidential candidates who were denouncing President Obama on Tuesday night for not fighting harder against the Islamic State, there’s an obvious if unspoken answer: Obama doesn’t think this is an existential battle that’s worth the cost to the United States of an all-out war.

You can disagree with Obama’s cost-benefit calculus, and with his past decisions on Syria and Iraq that got us to this point. But it’s evident that he has carefully weighed the dilemma of deeper U.S. involvement in the Middle East and decided it would be unwise. The comparison between Obama’s wary analysis and the often slapdash, half-baked proposals of GOP candidates at the debate was striking.

Obama appears to recognize that there’s a missing link in his strategy — the lack of a Sunni ground force that can reliably clear and hold the Islamic State’s heartland in Syria and Iraq. You can sense in his public statements that he sees two basic choices, given the weakness of these crucial Sunni allies:

● The United States could decide to go all-in with ground troops and provide the military muscle for Sunni moderates for the foreseeable future. That would start in Syria, but Obama’s advisers fear the commitment would expand to other collapsed Sunni states, such as Libya and Yemen. The United States , in effect, would become the governor of Sunnistan.

Obama clearly regards this option as a mistake. Advisers warn the monthly cost could be 100 U.S. troops killed, 500 wounded and $10 billion. Though Obama gets hammered on all sides for an allegedly feckless policy, he has resisted being forced into this commitment by a media firestorm that the White House sees as combining jihadist propaganda, GOP presidential politics and cable news hype.

● Obama prefers the slower, bumpier process of using S pecial Operations forces to partner with admittedly weak Sunni allies. In the near term, this strategy will be messy and sometimes painful, because the local forces are so disorganized. But the White House has concluded that, over time, it’s likely to be a more stable and sustainable approach.

Underlying Obama’s policy analysis is a view that the United States must get out of the business of trying to govern the Middle East. It’s clear from his public statements that he sees the region in the early stages of a messy transformation that will take a generation, and that quick fixes (or the appearance of them) can only be bought at an unacceptable cost.

The bottom line for Obama is that the United States shouldn’t overextend itself on projects on which it probably can’t deliver, which will further bleed the country. The United States must do something against the Islamic State — the threat to allies in Jordan, Saudi Arabia and Europe is too great — but Obama has shown he wants to limit U.S. involvement so that it doesn’t become all-consuming.

What would cause Obama to change his mind and treat the war against the Islamic State as an existential crisis requiring a major U.S. military intervention? Probably the trigger would be a big, orchestrated terrorist incident that so frightened the public that it began to prevent the normal functioning of America. At that point, Obama might decide there was no alternative to taking ownership of the Middle East mess with tens of thousands of U.S. troops.

Obama seems to have realized that he was slow to respond to public fear after the jihadist attacks in Paris and San Bernardino, Calif . His low-decibel approach led the public to worry he wasn’t doing enough to keep the country safe. Obama, not a cable television fan, apparently didn’t realize the state of anxiety.

The White House answer, judging by this week’s high-visibility visit to the Pentagon and a blizzard of updates on U.S. counterterrorism actions, is to be more aggressive in selling the activities that are underway. This will work only if the small-footprint approach shows success.

Calming the country is hard when GOP candidates are describing an inferno. But Obama seems convinced that the Republican proposals amount to more bombs and louder talk, rather than a coherent alternative strategy.

As the year ends, Obama would like to celebrate what he rightly sees as major achievements — an Iran nuclear deal, the Trans-Pacific Partnership on trade, reopening relations with Cuba and the climate change agreement reached in Paris. But there’s that persistent, toxic problem of Islamic terrorism emanating from the Middle East.

Obama will wait it out, if he can. But a major attack could force him to do the very thing he least wants as a legacy — send in the troops.

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