Example 3 Given the function $f(x)=\sin \left(x+\frac{\pi}{6}\right)+\sin \left(x-\frac{\pi}{6}\right)+a \cos x+b(a, b \in \mathbf{R}$ and are constants)
(1) Find the smallest positive period of the function $f(x)$;
(2) If $f(x)$ is monotonically increasing in the interval $\left[-\frac{\pi}{3}, 0\right]$, and can exactly achieve the minimum value of $f(x)$ as 2, try to find the values of $a$ and $b$.
Analysis: Simplifying the expression using trigonometric formulas is a necessary step.
Solution (1) \( f(x) = \sin x \cos \frac{\pi}{6} + \cos x \sin \frac{\pi}{6} + \sin x \cos \frac{\pi}{6} - \cos x \sin \frac{\pi}{6} + a \cos x + b = \sqrt{3} \sin x + a \cos x + b = \sqrt{a^{2}+3} \sin (x+\theta) + b \), where \( \sin \theta = \frac{a}{\sqrt{a^{2}+3}}, \cos \theta = \frac{\sqrt{3}}{\sqrt{a^{2}+3}} \). Therefore, the smallest positive period of \( f(x) \) is \( 2 \pi \).
(2) From (1), we know: the minimum value of \( f(x) \) is \( -\sqrt{a^{2}+3} + b \), so
\[
-\sqrt{a^{2}+3} + b = 2
\]

Also, the minimum value of \( f(x) \) in the interval \(\left[-\frac{\pi}{3}, 0\right]\) is \( f\left(-\frac{\pi}{3}\right) \), which is also 2, so
\[
f\left(-\frac{\pi}{3}\right) = -\frac{3}{2} + \frac{a}{2} + b = 2
\]

From (1) and (2), we get: \( a = -1, b = 4 \)