Since $Y$ is quasi-compact and quasi-separated, the same is true for $X$. By Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-pseudo-coherent-hocolim} we can write $K = \text{hocolim} K_n$ with $K_n$ perfect and $K_n \to K$ inducing an isomorphism on truncations $\tau_{\geq -n}$. Let $K_n^\vee$ be the dual perfect complex (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-dual-perfect-complex}). We obtain an inverse system $\ldots \to K_3^\vee \to K_2^\vee \to K_1^\vee$ of perfect objects. By Lemma \ref{lemma-perfect-relatively-perfect} we see that $K_n^\vee \otimes_{\mathcal{O}_X} E$ is $Y$-perfect. Thus we may apply Lemma \ref{lemma-derived-pushforward-rel-perfect} to $K_n^\vee \otimes_{\mathcal{O}_X} E$ and we obtain an inverse system $$ \ldots \to M_3 \to M_2 \to M_1 $$ of perfect complexes on $Y$ with $$ M_n = Rf_*(K_n^\vee \otimes_{\mathcal{O}_X}^\mathbf{L} E) = Rf_*R\SheafHom(K_n, E) $$ Moreover, the formation of these complexes commutes with any base change, namely $Lg^*M_n = Rf'_*((L(g')^*K_n)^\vee \otimes_{\mathcal{O}_{X'}}^\mathbf{L} L(g')^*E) = Rf'_*R\SheafHom(L(g')^*K_n, L(g')^*E)$. \medskip\noindent As $K_n \to K$ induces an isomorphism on $\tau_{\geq -n}$, we see that $K_n \to K_{n + 1}$ induces an isomorphism on $\tau_{\geq -n}$. It follows that $K_{n + 1}^\vee \to K_n^\vee$ induces an isomorphism on $\tau_{\leq n}$ as $K_n^\vee = R\SheafHom(K_n, \mathcal{O}_X)$. Suppose that $E$ has tor amplitude in $[a, b]$ as a complex of $f^{-1}\mathcal{O}_Y$-modules. Then the same is true after any base change, see Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-tor-independence-and-tor-amplitude}. We find that $K_{n + 1}^\vee \otimes_{\mathcal{O}_X} E \to K_n^\vee \otimes_{\mathcal{O}_X} E$ induces an isomorphism on $\tau_{\leq n + a}$ and the same is true after any base change. Applying the right derived functor $Rf_*$ we conclude the maps $M_{n + 1} \to M_n$ induce isomorphisms on $\tau_{\leq n + a}$ and the same is true after any base change. Choose a distinguished triangle $$ M_{n + 1} \to M_n \to C_n \to M_{n + 1}[1] $$ Pick $y \in |Y|$. Choose an elementary \'etale neighbourhood $(U, u) \to (Y, y)$; this is possible by Decent Spaces, Lemma \ref{decent-spaces-lemma-decent-space-elementary-etale-neighbourhood}. Take $Y'$ equal to the spectrum of the residue field at $u$. Pull back to see that $C_n|_U \otimes_{\mathcal{O}_U}^\mathbf{L} \kappa(u)$ has nonzero cohomology only in degrees $\geq n + a$. By More on Algebra, Lemma \ref{more-algebra-lemma-lift-perfect-from-residue-field} we see that the perfect complex $C_n|_U$ has tor amplitude in $[n + a, m_n]$ for some integer $m_n$ and after possibly shrinking $U$. Thus $C_n$ has tor amplitude in $[n + a, m_n]$ for some integer $m_n$ (because $Y$ is quasi-compact). In particular, the dual perfect complex $C_n^\vee$ has tor amplitude in $[-m_n, -n - a]$. \medskip\noindent Let $L_n = M_n^\vee$ be the dual perfect complex. The conclusion from the discussion in the previous paragraph is that $L_n \to L_{n + 1}$ induces isomorphisms on $\tau_{\geq -n - a}$. Thus $L = \text{hocolim} L_n$ is pseudo-coherent, see Derived Categories of Spaces, Lemma \ref{spaces-perfect-lemma-pseudo-coherent-hocolim}. Since we have $$ R\SheafHom(K, E) = R\SheafHom(\text{hocolim} K_n, E) = R\lim R\SheafHom(K_n, E) = R\lim K_n^\vee \otimes_{\mathcal{O}_X} E $$ (Cohomology on Sites, Lemma \ref{sites-cohomology-lemma-colim-and-lim-of-duals}) and since $R\lim$ commutes with $Rf_*$ we find that $$ Rf_*R\SheafHom(K, E) = R\lim M_n = R\lim R\SheafHom(L_n, \mathcal{O}_Y) = R\SheafHom(L, \mathcal{O}_Y) $$ This proves the formula over $Y$. Since the construction of $M_n$ is compatible with base chance, the formula continues to hold after any base change.