A search for direct top-squark pair production with Higgs or Z bosons in the decay final state is performed using a data sample of proton-proton collisions at ~TeV, collected by the CMS detector at the LHC that corresponds to an integrated luminosity of 19.5~fb. The search is performed in a sample of events containing leptons and b 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 models with pair production of a heavier top-squark mass eigenstate decaying to a lighter top-squark mass eigenstate via either or , followed in both cases by . The interpretation is performed in the region of signal mass parameter space , which so far is not probed by existing searches for direct top-squark pair production. The analysis excludes top squarks with masses ~GeV and ~GeV at the 95\% confidence level.