The Red Sox and right-handed reliever Chris Martin have agreed to a two-year, $17.5 million deal, sources told ESPN.