We study the nonequilibrium dynamics of two particles confined in two
spatially separated harmonic potentials and linearly coupled to the same
thermally fluctuating scalar field, a cartoon for optically trapped
colloids in contact with a medium close to a continuous phase
transition. When an external periodic driving is applied to one of these
particles, a nonequilibrium periodic state is eventually reached in
which their motion synchronizes thanks to the field-mediated effective
interaction, a phenomenon already observed in experiments. We fully
characterize the nonlinear response of the second particle as a function
of the driving frequency, in particular far from the adiabatic regime in
which the field can be assumed to relax instantaneously. We compare the
perturbative, analytic solution to its adiabatic approximation, thus
determining the limits of validity of the latter, and we qualitatively
test our predictions against numerical simulations.