Using a first-principles cluster expansion, we shed light on the solid-state phase diagram and structure of the recently discovered high-performance Pb-Ag-Sb-Te thermoelectrics. The calculated bulk thermodynamics favors the formation of coherent precipitates of ordered Ag(m)Sb(n)Te(m+n) phases immiscible with rocksalt PbTe, such as AgSbTe2. The solubility is high for Pb in AgSbTe2 and low for (Ag,Sb) in PbTe (8% vs 0.6% at 850 K). The differences in the phonon spectra of PbTe and AgSbTe2 suggest that these precipitates enhance the thermoelectric performance by lowering thermal conductivity.