To aid in the automation of inorganic materials synthesis, we introduce an algorithm (ARROWS3) that guides the selection of precursors used in solid-state reactions. Given a target phase, ARROWS3 iteratively proposes experiments and learns from their outcomes to identify an optimal set of precursors that leads to maximal yield of that target. Initial experiments are selected based on thermochemical data collected from first principles calculations, which enable the identification of precursors exhibiting large thermodynamic force to form the desired target. Should the initial experiments fail, their associated reaction paths are determined by sampling a range of synthesis temperatures and identifying their products. ARROWS3 then uses this information to pinpoint which intermediate reactions consume most of the available free energy associated with the starting materials. In subsequent experimental iterations, precursors are selected to avoid such unfavorable reactions and therefore maintain a strong driving force to form the target. We validate this approach on three experimental datasets containing results from more than 200 distinct synthesis procedures. When compared to several black-box optimization algorithms, ARROWS3 identifies the most effective set of precursors for each target while requiring substantially fewer experimental iterations. These findings highlight the importance of using domain knowledge in the design of optimization algorithms for materials synthesis, which are critical for the development of fully autonomous research platforms.