In the production of energy from fats, this is one of the enzymes that catalyzes the last step of the mitochondrial beta-oxidation pathway, an aerobic process breaking down fatty acids into acetyl-CoA. Using free coenzyme A/CoA, catalyzes the thiolytic cleavage of medium- to long-chain unbranched 3-oxoacyl-CoAs into acetyl-CoA and a fatty acyl-CoA shortened by two carbon atoms. Also catalyzes the condensation of two acetyl-CoA molecules into acetoacetyl-CoA and could be involved in the production of ketone bodies. Also displays hydrolase activity on various fatty acyl-CoAs.