A bipartisan group of senators has reached a long-sought agreement on changes to the criminal justice system that would reduce prison sentences for certain non-violent drug offenders. 

In the deal struck between some of the Senate's most conservative and liberal members, judges would have the discretion to give sentences below the mandatory minimum for non-violent drug offenders. Some current inmates could get their sentences reduced by as much as 25 percent by taking part in rehabilitation programs, if they are deemed a low risk to offend again. 

The bill is scheduled to be unveiled Thursday. Details were confirmed by a Senate aide familiar with the package. The aide, who spoke on condition of anonymity, was not authorized to speak publicly about the bill ahead of Thursday's announcement. 

Violent offenders, sex offenders and inmates convicted of terrorism charges would be excluded. Members of organized crime syndicates and major fraud offenders would also be excluded. 

The package was years in the making, the result of negotiations among some of the most powerful members of the Senate. Among their goals: make the sentencing system more fair, reduce recidivism and contain rising prison costs. 

Since 1980, the federal prison population has exploded, in part because of mandatory minimum sentences for non-violent drug offenders. In 1980, the federal prison population was less than 25,000. Today, it is more than 200,000. 

Among the Republican backers of the bill: John Cornyn of Texas, the No. 2 Republican in the Senate; Sen. Chuck Grassley of Iowa, chairman of the Senate Judiciary Committee; Sen. Mike Lee of Utah; and Sen. Lindsey Graham of South Carolina, who is running a longshot campaign for president. 

Among the Democrats: Sen. Dick Durbin of Illinois, the No. 2 Democrat in the Senate; Sen. Chuck Schumer of New York, the No. 3 Democrat; Sen. Sheldon Whitehouse of Rhode Island; and Sen. Cory Booker of New Jersey.