Senate Republicans and Democrats have reached a “deal in principle” for an emergency funding bill to address the surge in migrants at the U.S.-Mexico border, including the care of detained families and children. Senate aides confirm the deal would fund approximately $4.5 billion dollars and was worked out by Appropriations Chairman Richard Shelby, R-Ala., and the ranking Democrat on the committee, Patrick Leahy, D-Vt.

Both offices are expected to release details Wednesday, as the Senate Appropriations Committee plans to mark up its version of the legislation and send it to the full Senate.

Government agencies have warned that funds to care for families and children is on track to run out as soon as the end of June.

The agreement is a significant breakthrough after months of discussion, but final passage is not a guarantee.

The House of Representatives and White House must still get on board, and both have entered recent immigration talks with steadfast beliefs. House Democrats have repeatedly pushed for more humanitarian requirements on the treatment of immigrants and restrictions on how many of them can be detained at any one time, while President Donald Trump has routinely used funding battles to demand more resources for a border wall.

All parties involved face time pressure, as government agencies have warned that funds to care for families and children is on track to run out as soon as the end of June.

Border agents have seen a surge in migrants at the border in recent months, particularly those arriving as family units, though the number of arrests at the border have fallen in the last few weeks. Officials say it’s a change that presents a challenge to, among other things, facilities used to accommodating mostly single males.

Meanwhile, top-level negotiations over paying the country’s bills and funding about $1.3 trillion in agency budgets are set to reconvene Wednesday, in an effort to head off a financial train wreck when a series of deadlines hit this fall.

The bipartisan budget talks are aimed at preventing automatic spending cuts threatening the top priorities of both Democrats and Republicans. McConnell and House Speaker Nancy Pelosi are taking the lead, along with Treasury Secretary Steven Mnuchin and Mick Mulvaney, President Donald Trump’s chief of staff.

Wednesday afternoon’s talks — on double-barreled legislation to set new “caps” on spending accounts controlled by Congress and also increase the government’s so-called debt limit — are intended to set a more orderly fiscal agenda that would permit relatively routine passage of both spending bills and drama-free consideration of the debt limit legislation, required this fall to avert a market-rattling default on U.S. obligations like bond payments.

“Our guys are going to have to be flexible going in, the president’s going to have to be flexible if he wants to get his defense number, and obviously he’s going to have to work with the Democrats on some of things they want to get done.”

It won’t be easy. An early burst of optimism after an initial round of meetings late month has faded. Democrats are moving ahead with legislation — also slated to pass on Wednesday — that spends way more on domestic programs than Trump has requested, while curbing his Pentagon request.

House Democrats are going ahead with spending bills, but all sides are working on a separate track to strike a deal on the overall amount of money to be allocated for defense and nondefense appropriations this year.

Without an agreement, another round of automatic cuts to government spending called sequestration would strike early next year, cutting $70 billion from current levels for the military and another $55 billion from nondefense programs.

The muddled picture has sparked concerns of another government shutdown, the return of an automatic $125 billion in spending cuts to the Pentagon and domestic agencies, and a first-ever default on U.S. government obligations like interest payments.

“Our guys are going to have to be flexible going in, the president’s going to have to be flexible if he wants to get his defense number, and obviously he’s going to have to work with the Democrats on some of things they want to get done,” said No. 2 Senate Republicans John Thune of South Dakota.