If $f$ is proper, then $f^! = a$ and we can use (\ref{equation-compare-with-pullback}) and if $g$ is also proper, then Lemma \ref{lemma-transitivity-compare-with-pullback} proves the commutativity of the diagram (in greater generality). \medskip\noindent Let us define the map $\mu_{f, K}$. Choose a compactification $j : X \to \overline{X}$ of $X$ over $Y$. Since $f^!$ is defined as $j^* \circ \overline{a}$ we obtain $\mu_{f, K}$ as the restriction of the map (\ref{equation-compare-with-pullback}) $$ L\overline{f}^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L} \overline{a}(\mathcal{O}_Y) \longrightarrow \overline{a}(K) $$ to $X$. To see this is independent of the choice of the compactification we argue as in the proof of Lemma \ref{lemma-shriek-well-defined}. We urge the reader to read the proof of that lemma first. \medskip\noindent Assume given a morphism $g : \overline{X}_1 \to \overline{X}_2$ between compactifications $j_i : X \to \overline{X}_i$ over $Y$ such that $g^{-1}(j_2(X)) = j_1(X)$. Denote $\overline{c}$ the right adjoint for pushforward of Lemma \ref{lemma-twisted-inverse-image} for the morphism $g$. The maps $$ L\overline{f}_1^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L} \overline{a}_1(\mathcal{O}_Y) \longrightarrow \overline{a}_1(K) \quad\text{and}\quad L\overline{f}_2^*K \otimes_{\mathcal{O}_{\overline{X}}}^\mathbf{L} \overline{a}_2(\mathcal{O}_Y) \longrightarrow \overline{a}_2(K) $$ fit into the commutative diagram $$ \xymatrix{ Lg^*(L\overline{f}_2^*K \otimes^\mathbf{L} \overline{a}_2(\mathcal{O}_Y)) \otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2}) \ar@{=}[d] \ar[r]_-\sigma & \overline{c}(L\overline{f}_2^*K \otimes^\mathbf{L} \overline{a}_2(\mathcal{O}_Y)) \ar[r] & \overline{c}(\overline{a}_2(K)) \ar@{=}[d] \\ L\overline{f}_1^*K \otimes^\mathbf{L} Lg^*\overline{a}_2(\mathcal{O}_Y) \otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2}) \ar[r]^-{1 \otimes \tau} & L\overline{f}_1^*K \otimes^\mathbf{L} \overline{a}_1(\mathcal{O}_Y) \ar[r] & \overline{a}_1(K) } $$ by Lemma \ref{lemma-transitivity-compare-with-pullback}. By Lemma \ref{lemma-compare-on-open} the maps $\sigma$ and $\tau$ restrict to an isomorphism over $X$. In fact, we can say more. Recall that in the proof of Lemma \ref{lemma-shriek-well-defined} we used the map (\ref{equation-sheafy}) $\gamma : j_1^* \circ \overline{c} \to j_2^*$ to construct our isomorphism $\alpha_g : j_1^* \circ \overline{a}_1 \to j_2^* \circ \overline{a}_2$. Pulling back to map $\sigma$ by $j_1$ we obtain the identity map on $j_2^*\left(L\overline{f}_2^*K \otimes^\mathbf{L} \overline{a}_2(\mathcal{O}_Y)\right)$ if we identify $j_1^*\overline{c}(\mathcal{O}_{\overline{X}_2})$ with $\mathcal{O}_X$ via $j_1^* \circ \overline{c} \to j_2^*$, see Lemma \ref{lemma-restriction-compare-with-pullback}. Similarly, the map $\tau : Lg^*\overline{a}_2(\mathcal{O}_Y) \otimes^\mathbf{L} \overline{c}(\mathcal{O}_{\overline{X}_2}) \to \overline{a}_1(\mathcal{O}_Y) = \overline{c}(\overline{a}_2(\mathcal{O}_Y))$ pulls back to the identity map on $j_2^*\overline{a}_2(\mathcal{O}_Y)$. We conclude that pulling back by $j_1$ and applying $\gamma$ wherever we can we obtain a commutative diagram $$ \xymatrix{ j_2^*\left(L\overline{f}_2^*K \otimes^\mathbf{L} \overline{a}_2(\mathcal{O}_Y)\right) \ar[r] \ar[d] & j_2^*\overline{a}_2(K) \\ j_1^*L\overline{f}_1^*K \otimes^\mathbf{L} j_2^*\overline{a}_2(\mathcal{O}_Y) & j_1^*(L\overline{f}_1^*K \otimes^\mathbf{L} \overline{a}_1(\mathcal{O}_Y)) \ar[r] \ar[l]_{1 \otimes \alpha_g} & j_1^* \overline{a}_1(K) \ar[lu]_{\alpha_g} } $$ The commutativity of this diagram exactly tells us that the map $\mu_{f, K}$ constructed using the compactification $\overline{X}_1$ is the same as the map $\mu_{f, K}$ constructed using the compactification $\overline{X}_2$ via the identification $\alpha_g$ used in the proof of Lemma \ref{lemma-shriek-well-defined}. Some categorical arguments exactly as in the proof of  Lemma \ref{lemma-shriek-well-defined} now show that $\mu_{f, K}$ is well defined (small detail omitted). \medskip\noindent Having said this, the commutativity of the diagram in the statement of our lemma follows from the construction of the isomorphism $(g \circ f)^! \to f^! \circ g^!$ (first part of the proof of Lemma \ref{lemma-upper-shriek-composition} using $\overline{X} \to \overline{Y} \to Z$) and the result of Lemma \ref{lemma-transitivity-compare-with-pullback} for $\overline{X} \to \overline{Y} \to Z$.