Compatibility between the functors of $\mathcal{O}_X$-modules and $\mathcal{D}_X$-modules Let $f:X\to Y$ be a morphism between smooth algebraic varieties over $\mathbb{C}$.
We have natural functors $f^!:\mathsf{D}_{\text{qc}}(\mathcal{D}_Y)\to \mathsf{D}_{\text{qc}}(\mathcal{D}_X)$, $f_*:\mathsf{D}_{\text{qc}}(\mathcal{D}_X)\to \mathsf{D}_{\text{qc}}(\mathcal{D}_Y)$, and $\mathbb{D}_X:\mathsf{D}_{\text{qc}}(\mathcal{D}_X)\to \mathsf{D}_{\text{qc}}(\mathcal{D}_X)^\text{op}$ between the (unbounded, but feel free to think about the bounded case if you prefer) derived categories of left D-modules (i.e. the objects are complexes of D-modules with quasi-coherent cohomology). Naturally, we can form the diagrams below.

(The vertical arrows are simply the functors which forgets the D-module structure, and the arrows below are the functors in Grothendieck duality.)
My main question is: do these diagrams commute? If the third diagram does not commute, does it commute when restricted to $\mathsf{D}^b_{\text{coh}}$? Also, what happens for right D-modules?
 A: [All functors in this answer are assumed to be derived]
These commutativities basically boil down to unraveling all definitions. The actual computations are quite annoying (but totally possible), so I will only explain the main points.

*

*The diagram commutes for $f^*$ and left $\mathcal{D}$-modules. This basically follows from the definition (do not confuse it with the other $f^*_{\mathcal{D}}$ functor that is defined only on holonomic $\mathcal{D}$-modules).


*The functor $f^!$ on left $\cal{D}$-modules is defined as $f^*[\mathrm{dim}_X -\mathrm{dim}_Y]$ for a morphism of smooth varieties $f\colon X \to Y$. In particular $f^!(\mathcal{O}_Y) \simeq \mathcal{O}_X[\mathrm{dim}_X - \mathrm{dim}_Y]$, so there is no chance that the first diagram in your post commutes.


*Before we discuss what happens for right $\mathcal{D}$-modules, we need to recall the so-called "left-right switch". This is a canonical equivalence between left and right $\mathcal{D}$-modules on any smooth variety $X$. Namely, it is given by the tensor product functor $-\otimes_{\mathcal{O}_X} \omega_X\colon \mathrm{D}^b_{qc}(\mathrm{LMod}_{\mathcal{D}_X}) \to \mathrm{D}^b_{qc}(\mathrm{RMod}_{\mathcal{D}_X})$. One needs to actually make sense of this, roughly the point is that the canonical bundle $\omega_X$ has a canonical structure of a right $\mathcal{D}$-module via Lie derivatives. Then a tensor product over the structure sheaf of a left $\mathcal{D}$-module and a right $\mathcal{D}$-module has a canonical structure of a right $\mathcal{D}$-module.


*Now we are ready to discuss what happens for the $f^!$ functor on the level of right $\mathcal{D}$-modules. In order to avoid any confusion, let us denote it by $f^{\dagger}$. It is defined via the left-right switch. Namely, $f^\dagger(M):= f^!(M\otimes_{\mathcal{O}_Y} \omega^{\vee}_Y)\otimes_{\mathcal{O}_X} \omega_X \colon \mathrm{D}^b_{qc}(\mathrm{RMod}_{\mathcal{D}_Y}) \to \mathrm{D}^b_{qc}(\mathrm{RMod}_{\mathcal{D}_Y})$ for a morphism $f\colon X \to Y$ of smooth varieties. Now we use steps $1$ and $2$ to compute this functor (on the level of underlying $\mathcal{O}$-modules)
$$
f^\dagger(M) = f^!(M\otimes_{\mathcal{O}_Y}\omega^{\vee}_Y) \otimes_{\mathcal{O}_X} \omega_X= f^*(M) \otimes_{\mathcal{O}_X} f^*(\omega^\vee_Y)[\mathrm{dim}_X-\mathrm{dim}_Y]\otimes_{\mathcal{O}_X} \omega_X
$$
$$
=f^*(M)\otimes_{\mathcal{O}_X} f^*(\omega^{\bullet, \vee}_Y) \otimes_{\mathcal{O}_X} \omega_X^\bullet
$$
where $\omega_X^\bullet$ is the dualizing complex on $X$, so $\omega_X^\bullet = \omega_X[\mathrm{dim}_X]$, and the same for $Y$. Now any finite type morphism of regular scheme is of finite Tor-amplitude, so Tag0B6U gives us that
$$
f^!(M)=f^*(M)\otimes_{\mathcal{O}_X} f^!(\mathcal{O}_Y)
$$
and, essentially by definition,
$$
\omega^\bullet_X = f^!(\omega^\bullet_Y) = f^*(\omega^\bullet_Y) \otimes_{\mathcal{O}_X} f^!(\mathcal{O}_Y).
$$
Combining these two equalities, we get the desired formula
$$
f^!(M) = f^*(M)\otimes_{\mathcal{O}_X} \omega^\bullet_X \otimes_{\mathcal{O}_X} f^*(\omega^{\bullet, \vee}_Y) = f^\dagger(M)
$$


*The diagram for $f_*$ does not commute neither for left nor for right $\mathcal{D}$-modules because it is neither left nor right $t$-exact on the $\mathcal{D}$-module side (consider separately cases of a closed immersion and a smooth morphism) but it is left exact on the $\mathcal{O}$-module side. However, one can ask for commutativity of another diagram that relates $\mathcal{O}$-modules and $\mathcal{D}$-modules. Namely, given any object $K\in \mathrm{D}_{qc}^b(\mathcal{O}_Y)$, one can define an induced $\mathcal{D}$-module $K\otimes_{\mathcal{O}_Y}\mathcal{D}_Y \in \mathrm{D}^b_{qc}(\mathcal{D}_Y)$. Then the claim is that for the right $\mathcal{D}$-modules, there is a functorial isomorphism
$$
f_*(K\otimes_{\mathcal{O}_X} \mathcal{D}_X) \simeq f_*(K) \otimes_{\mathcal{O}_Y} \mathcal{D}_Y
$$
for a morphism $f\colon X \to Y$ of smooth varieties. The proof essentially boils down to the projection formula (and a bit tedious computations since you want to identify those objects as $\mathcal{D}$-modules and not merely $\mathcal{O}$-modules) once all definitions are given (but it is quite tricky to define $f_*$ on the $\mathcal{D}$-module side). A version of this result is Lemma 4.26 in Kashiwara's book "$\mathcal{D}$-modules and microlocal analysis" (actually formulated for left $\mathcal{D}$-modules).


*Commutativity of your last diagram depends on your definition of duality on both sides, I think.
