The deal is contingent upon Petit, 33, passing a physical, likely to be scheduled for next week after the reliever travels from his home in Venezuela.
Petit, 10-year veteran whose ability to gobble up innings was coveted, pitched 91 1/3 innings in 60 appearances for the Los Angeles Angels last season while posting a 101/18 strikeout-to-walk ratio and a 2.76 ERA.
He would earn $3.5 million next year and $5.5 million in 2019, and the contract includes a $5.5 million for 2020 with a $1 million buyout.
He will return to pitch in the Bay Area after spending the 2012-15 seasons across the bay with the San Francisco Giants, helping them win World Series in '12 and '14.
Petit had a base salary of $2.25 million last season. He has also pitched for the Nationals, Diamondbacks and Marlins over his career.
The Associated Press contributed to this report.