A search for supersymmetry through the direct pair production of top squarks, with Higgs (H) or Z bosons in the decay chain, is performed using a data sample of proton–proton collisions at √s=8TeVcollected in 2012 with the CMS detector at the LHC. The sample corresponds to an integrated luminosity of 19.5fb−1. The search is performed using a selection of events containing leptons and bottom-quark jets. No evidence for a significant excess of events over the standard model background prediction is observed. The results are interpreted in the context of simplified supersymmetric models with pair production of a heavier top-squark mass eigenstate ˜ t2decaying to a lighter top-squark mass eigenstate ˜t1via either ˜t2→H˜ t1or ˜t2→Z˜ t1, followed in both cases by ˜t1→t˜ χ01, where ˜ χ01is an undetected, stable, lightest supersymmetric particle. The interpretation is performed in the region where the mass difference between the ˜ t1and ˜ χ01states is approximately equal to the top-quark mass (m˜ t1−m˜ χ01mt), which is not probed by searches for direct ˜ t1squark pair production. The analysis excludes top squarks with masses m˜ t2\u3c575GeVand m˜ t1\u3c400GeVat a 95% confidence level