How should the government respond to automation? We study this question in a heterogeneous agent model that takes worker displacement seriously. We recognize that displaced workers face two frictions in practice: reallocation is slow and borrowing is limited. We analyze a second best problem where the government can tax automation but lacks redistributive tools to fully alleviate borrowing frictions. The equilibrium is (constrained) inefficient and automation is excessive. Firms do not internalize that automation depresses the income of automated workers early on during the transition, precisely when they become borrowing constrained. The government finds it optimal to slow down automation on efficiency grounds, even when it does not value equity. Quantitatively, the optimal speed of automation is considerably lower than at the laissez-faire. The optimal policy improves efficiency and delivers meaningful welfare gains.