In off-policy MC control algorithm by Sutton & Barto, why do we perform a last update when sample action is inconsistent with target policy?
I think that this is an intentional subtle detail of the algorithm that ensures the convergence property.  The claim in the book is that for any $b$ that provides us with &quot;an infinite number of returns for each pair of state and action&quot; the target policy $\pi$ will converge to optimal.
Imagine now that we have such a bad policy $b$ that it never aligns with the target policy action at the last step $t=T-1$ of each generated episode: $A_{T-1} = \pi(S_{T-1})$. In that case the weight value will stay $W=1$ and the the algorithm will be reduced to (ignoring $t$ indices for the last $S,A,R$ triplet):
$$\begin{array}{l} C(S,A) \leftarrow C(S,A) + 1 \\ 
Q(S,A) \leftarrow Q(S,A) + \frac{1}{C(S,A)}\left[R - Q(S,A)\right]
\end{array}$$
Which is just the tabular incremental averaging for the Q values (see for example eq. (2.3)).
If we bail from the for loop before these updates, then no updates would happen at all. And authors won't be able to claim convergence to optimal policy for all those &quot;good&quot; sampling policies $b$.