I'm not sure what kind of conditions you have in mind but it is true that for every $r>1$ there is a uniform pro-$p$ group $G$ where it is not true that $G$ is not a semidirect product of $H$ and $\mathbb{Z}_p^r$.
To see this consider the uniform pro-$p$ group of dimension $r+1$ with generators $x,y,z,a_1,\ldots,a_{r-2}$ (for some $r\geq 2$) with $z,a_1,\ldots,a_n$$z,a_1,\ldots,a_{r-2}$ all central and $xyx^{-1}y^{-1}=z^p$. Then $G'$ is generated by $z^p$ and so $H$ is generated by $z$ and $G/H\cong \mathbb{Z}_p^{r}$. However it is easy to see that any subgroup of $G$ isomorphic to $\mathbb{Z}_p^r$ contains some non-trivial power of $z$.
Indeed, I think a similar argument works for any nilpotent $G$ that is not abelian.