The Philadelphia Phillies and Cole Hamels have agreed to a six-year contract extension worth a little more than $140 million, pending physical, sources said Wednesday.