Wednesday morning, The New York Times noted that Donald Trump entered autumn with the toughest test of his deal-making ability thus far ahead of him. And Wednesday afternoon, the president provided a riposte by striking a deal.

But the deal he struck is more of a win for Democrats than it is for his Republican allies in Congress. It funds the government through December 15, raises the debt ceiling, and procures funding for disaster relief. Trump agreed to the deal over the heated objections of GOP leaders, who see it as a capitulation to Democrats—the plan was the brainchild of Senate Minority Leader Chuck Schumer and House Minority Leader Nancy Pelosi—that sets congressional Republicans up to get rolled again in December.

Trump, however, displayed little hesitation in bucking his own party’s leaders in Congress. This is, in a way, a another example of Trump’s shallow, weak fidelity to the institution and platform of the GOP, but it has deeper roots in the president’s temperament. There’s a reason his famous book is titled The Art of the Deal and not The Art of Carefully, Slowly Outflanking Your Negotiating Partner: The president’s bias is often toward action, not about the details of the deal that emerges. In part, that’s a remnant of his days in real estate, where development deals were often mutually beneficial, and everyone wanted them. But that’s not the case in politics, where obstruction is often the most profitable course. In this case, it’s also a byproduct of Trump’s ideological agnosticism on many issues, which produces an indifference to the substance of any deal, so long as it’s struck.

Over the last few months, Congress has gotten next to nothing done. That’s both a product of Trump’s inattention and mercurial moods, but also a source of them: He has repeatedly lashed out at GOP members of Congress, and in particular Senate Majority Leader Mitch McConnell, for their failure to, among other things, repeal and replace the Affordable Care Act. The president has been notably unhelpful in the process: Not only has he been unable to use his persuasive powers to great effect on members, he keeps changing what he wants out of a bill.

Trump entered the negotiation saying he wanted to repeal and replace Obamacare, but he also wanted to expand coverage and lower premiums—a more or less impossible mandate without expanding government’s role, a no-no for Republicans. During the process, he was apt to whipsaw in his view, for example throwing a Rose Garden party to celebrate the passage of a House bill and then blasting it as “mean” as he spoke to Senate Republicans.

This vacillation was impossible for Republicans to understand, because many of them had actual desires for what the bill would accomplish. Trump’s greatest interest was simply getting the bill, and being able to say he repealed and replaced Obamacare. That, in turn, meant he never grasped why differing priorities among Republicans prevented them from coming to a deal. The inaction grated on Trump; he couldn’t fathom why John McCain would deliver a procedural vote to move repeal forward and then vote against the final deal. It’s part of why he appears to be the last man remaining in Washington who believes that tax reform might happen.

That’s the context for Wednesday’s meeting with congressional leaders. Trump has no particular ideological commitments on raising the debt ceiling. “Always we’ll agree on debt ceiling automatically because of the importance of it,” Trump said afterwards. (He hasn’t always felt that way, bashing congressional Republicans for giving up increase in 2013; but then changing one’s mind about the debt ceiling after becoming president is something of a tradition, as Barack Obama shows.) Funding FEMA is an important executive-branch priority. And Trump has no particular dogma on funding the government, either: Though he has threatened to take hostages in exchange for keeping the government running, his hostage of choice is funding for his border wall—not, say, fiscally conservative spending cuts.

Congressional GOP leaders have all sorts of hesitations. On the offensive side of the ball, they’d like to cut government spending, for example, and achieve other conservative policy goals, and must-pass measures like disaster relief, the debt ceiling, and the funding resolution are chances to ram those through. On the defensive side of the ball, they don’t want to give Democrats a chance to pressure them into certain goals later on. That made McConnell and Speaker Paul Ryan want to extend the debt ceiling into late 2018, after the midterm elections, but it did not appear they had enough Republican votes to do so without Democratic help.

Into this situation walked Pelosi and Schumer, with whom Trump has claimed he wants to work but whom he keeps insulting—tellingly, usually as “obstructionists.” While McConnell and Ryan counseled caution, the Democrats came to a White House meeting with a deal in hand: Democrats would vote to raise the debt ceiling, keep the government open, and fund disaster relief, but only until mid-December. Ryan accused the Democrats of “playing politics” with disaster and called the idea “ridiculous and disgraceful.”

But Trump, ever eager to find a deal, took them up on it. Republicans were furious. Not only had Trump given away the farm Wednesday, betraying his own party, but he was setting up another disaster in December, with the new fiscal cliff. Then Republican leaders will once again face default and a shutdown, and they’ll need Democratic votes to avert it. And at that point, Democrats can make new demands—for example, forcing a vote on a clean version of DACA, the program for undocumented immigrants brought to the U.S. as children.

That’s frustrating for Paul Ryan, who has a host of conservative policies he’d like to enact and a restive caucus that will be furious at him (and some of whom might try to oust him) if Democratic votes help pass a DACA replacement with no concessions. Trump doesn’t care, though. In killing DACA on Tuesday, the administration heavily emphasized the notion that DACA was executive overreach, and offered Congress a six-month window to implement its own fix. Trump had left himself little option but to kill DACA—he’d promised repeatedly to end it, and faced pressure from hardliners in his inner circle and in his base—but would probably rather not see it actually go away, since “Dreamers” are a sympathetic bunch, deportation would be outlandishly expensive, and polls show a vast majority of Americans want to allow those subject to DACA to stay. Trump might be just as happy to see a clean DACA replacement.

“Chuck and Nancy would like to see something happen, and so do I,” he said on Air Force One Wednesday afternoon, chummily first-naming his new pals. He didn’t bother to mention Ryan and McConnell.

If that’s what happens, Trump will have probably forgotten how he got there, and will rail against Democrats for not funding the border wall. That, too, will fit the pattern: Once again, he’ll be inattentive to detail, and once again, he’ll be baffled why Congress won’t fund the border wall, even if it’s impractically expensive or ineffective. After all, it’s always better to do something than nothing, right?