4. Given the sequence $\left\{a_{n}\right\}(n>0)$ satisfies:
$$
a_{1}=1, a_{n+1}=\sqrt{2+a_{n}} \text {. }
$$

then the general term formula of $\left\{a_{n}\right\}$ is
4. $2 \cos \frac{\pi}{3 \times 2^{n-1}}$.

Let $a_{n}=2 \cos x_{n}\left(n \in \mathbf{Z}_{+}\right), x_{1}=\frac{\pi}{3}$.
By the problem, we know $a_{n}>0$.
By $a_{n+1}=\sqrt{2+a_{n}}$
$$
\begin{array}{c}
\Rightarrow 2 \cos x_{n+1}=\sqrt{2+2 \cos x_{n}} \\
=\sqrt{4 \cos ^{2} \frac{x_{n}}{2}}=2 \cos \frac{x_{n}}{2} \\
\Rightarrow x_{n+1}=\frac{x_{n}}{2} \Rightarrow x_{n}=\frac{\pi}{3 \times 2^{n-1}} .
\end{array}
$$

Thus, $a_{n}=2 \cos \frac{\pi}{3 \times 2^{n-1}}$.