13. Given the function $f(x)=\sin \left(x+\frac{\pi}{6}\right)+\sin \left(x-\frac{\pi}{6}\right)+\cos x+a(a \in \mathbf{R}, a$ is a constant $)$,
(I) Find the smallest positive period of the function $f(x)$.
(II) If the maximum value of $f(x)$ is 1, find the value of $a$.
(III) If $x \in\left[-\frac{\pi}{2}, \frac{\pi}{2}\right]$ when the maximum value of $f(x)$ is 1, find the value of $a$.
13. ( I ) $f(x)=\sqrt{3} \sin x+\cos x+a$
$$
=2 \sin \left(x+\frac{\pi}{6}\right)+u \text {. }
$$

So the smallest positive period of $f(x)$ is $2 \pi$.
(II) From H(1), the maximum value of $f(x)$ is $2+a$.

Therefore, $2+a=1$. Thus, $a=-1$.
(III) Since $x \in\left[-\frac{\pi}{2}, \frac{\pi}{2}\right]$.

Then $x+\frac{\pi}{6} \in\left[-\frac{\pi}{3}, \frac{2}{3} \pi\right]$.
So the maximum value of $f(x)$ is $2+a$.
Thus, $2+a=1$, which means $a=-1$.