We consider an equilibrium search model and employment contracts when workers have endogenous on-the-job search. When a firm tries to retain an employee by matching outside offers, variable search intensity leads to a moral hazard problem. We first consider workers with identical productivities. We derive an equilibrium where firms commit not to respond to outside offers and workers search less. Second, we investigate the case with heterogeneous workers and asymmetric information. Assuming that firms can commit to retain all workers irrespective of their ability, we establish conditions under which it is optimal to do so. This policy again reduces the incentive for active on-the-job search. We discuss an equilibrium where all firms use these so-called ‘pooling’ contracts.