We introduce uncertainty into Holmstrom and Milgrom (1987) to study optimal longterm contracting with learning. In a dynamic relationship, the agent's shirking not only reduces current performance, but also increases the agent's information rent due to the persistent belief manipulation effect.We characterize the optimal contract using the dynamic programming technique in which information rent is the unique state variable. In the optimal contract, the optimal effort is front-loaded and stochastically decreases over time. Furthermore, the optimal contract exhibits an option-like feature in that incentives increase after good performance. Implications about managerial incentives and asset management compensations are discussed.