Trump's calculus appears to be to strike when U.S. personnel are harmed, or U.S. soil (i.e., the U.S embassy in Bagdhad) is attacked.
He held his fire when the Iranians shot down a U.S. drone, and when their proxies attacked Saudi oil installations. But he struck following the death of a U.S. contractor and our embassy being attacked. This appears to be the dividing line for his base, who want us to scale back our involvement in foreign wars, but not to compromise our security or coddle those who harm our people.
The Iranians staged a careful tit for tat. Significantly, their response was launched from Iranian soil, not by their proxies, and targeted U.S. personnel in Iraq, just as we killed theirs in Iraq. But the attack was not against an American base, but rather Iraqi bases where Americans are housed. And most significantly, for whatever reason, they appear to have missed and harmed no Americans.
So the stage is set for the U.S. to stand down, call their bluff and let them make any next move. If and when U.S. personnel are harmed, or the U.S homeland attacked, we will have the upper hand morally to take their assets out. In the meantime, Trump's bold act appears to have worked and the Iranians are carefully calibrating just what they can do going forward. As for Trump's ultimate goal of bringing our troops home from Iraq and Afghanistan, I think this all helps set the stage for that goal to be achieved.