For two graphs $F,H$ and a positive integer $n$, the function $f_{F,H}(n)$ denotes the largest $m$ such that every $H$-free graph on $n$ vertices contains an $F$-free induced subgraph on $m$ vertices. This function has been extensively studied in the last 60 years when $F$ and $H$ are cliques and became known as the ErdH{o}s-Rogers function. Recently, Balogh, Chen and Luo, and Mubayi and Verstra"ete initiated the systematic study of this function in the case where $F$ is a general graph. Answering, in a strong form, a question of Mubayi and Verstra"ete, we prove that for every positive integer $r$ and every $K_{r-1}$-free graph $F$, there exists some $varepsilon_F>0$ such that $f_{F,K_r}(n)=O(n^{1/2-varepsilon_F})$. This result is tight in two ways. Firstly, it is no longer true if $F$ contains $K_{r-1}$ as a subgraph. Secondly, we show that for all $rgeq 4$ and $varepsilon>0$, there exists a $K_{r-1}$-free graph $F$ for which $f_{F,K_r}(n)=Omega(n^{1/2-varepsilon})$. Along the way of proving this, we show in particular that for every graph $F$ with minimum degree $t$, we have $f_{F,K_4}(n)=Omega(n^{1/2-6/sqrt{t}})$. This answers (in a strong form) another question of Mubayi and Verstra"ete. Finally, we prove that there exist absolute constants $0