The Arizona Diamondbacks have agreed to a four-year contract extension with shortstop Nick Ahmed, the team announced Monday.