I'm trying to learn a little about Grothendieck duality. One version of the theorem states that if $f: X \to Y$ is a proper morphism of schemes, then the induced functor on derived categories $f_*: D^+(\mathrm{QCoh}(X)) \to D^+(\mathrm{QCoh}(Y))$ has a right adjoint $f^!$ (and under nice hypotheses, these will preserve the subcategories with coherent cohomology). The existence of an adjoint can be proved via adjoint functor arguments, even without assuming $f$ proper; this was done, e.g., by Neeman. (The point is that a triangulated functor between nice triangulated categories (or, stable $\infty$-categories) which preserves coproducts is a left adjoint.)

However, in trying to identify $f^{!}$, we might want to be able to localize on $X$ and $Y$, and thus deal with the non-proper case. My understanding is that the upper-shriek functor $f^{!}$ there is not supposed to be the right adjoint to $f_{\ast}$: for example, for an open immersion it should be the upper-star $f^*$.

In the topological version, one can define a $f_{!}$ functor for sheaves (push-forward with compact support) and $f^!$ is the right adjoint to $f_{!}$. Is there any "functorial" way to interpret $f^{!}$ when $f$ is not proper?