Here is an alternative, somewhat simpler, counterexampleNote: This answer used to be a counterexample that given by Christophe Leuridan:missed the mark.
LetThe way to get around he definitional issues with conditional expectations is to work with $X=A=[0,1]$regular conditional probabilities in product form, $u(x,a)=-(x-a)^2$ andwhich guarantee that all conditional expectations fit together well. In particular, there exists a measurable function $\pi$ is(or a transition probability, essentially the "uniform distribution" onsame thing) $\kappa:A\to X$ such that for $\pi_A$ the line segment $X\times\{0\}$. Here$A$-marginal of $\pi$, choosing awe have for every Borel set $E\subseteq X\times A$ that $$\pi(E)=\int\int 1_E(x,a)~\mathrm d\kappa_a(x)~\mathrm d\pi_A(a).$$ The function $f\in\mathcal{F}$ amounts$\kappa$ is unique up to choosing a point in $A$$\pi_A$-null sets. Then the optimal choice on the
That way, one can show that $$\max_{f\in \mathcal{F}}\int_{X\times A} u\big(x,f(a)\big)~\mathrm d\pi(x,a) =\max_{f\in \mathcal{F}}\int_A \int_X u\big(x,f(a)\big)~\mathrm d\kappa_a(x) ~\mathrm d\pi_A(a)$$ $$= \int_A \max_{f\in \mathcal{F}} \int_X u\big(x,f(a)\big)~\mathrm d\kappa_a(x) ~\mathrm d\pi_A(a).$$ The left involves findingside is trivially no larger than the pointright side. For the other direction, you show that minimizes the average squared distancecorrespondence that associates to each $x$, which will be$a$ the argmax of $1/2$$\int_X u\big(x,\cdot\big)~\mathrm d\kappa_a(x)$ is measurable with nonempty compact values. ButSo you can use the Kuratowski-Ryll-Nardzewski measurable selection theorem to turn a solution for the problem on the right, you can optimize conditional to a solution of the problem on each individualthe left, which must, therefore, give the same value.
The argument does not require $x$$X$ to be compact, so you can chooseany Polish space will do, and $a=x$ there$u$ need not be continuous in $X$, any bounded (or integrably bounded) Carathéodory function will do.