4. Let the base $A B C D$ of the right square prism $A B C D-A_{1} B_{1} C_{1} D_{1}$ be a unit square. If the dihedral angle $A_{1}-B D-C_{1}$ is $\frac{\pi}{3}$, then $A A_{1}=$ $\qquad$ .
Given that the center of the base $ABCD$ is $O$, then $\angle A_{1} O C_{1}$ is the plane angle of the dihedral angle $A_{1}-B D-C_{1}$. Therefore,
$$
\begin{array}{l}
\angle A_{1} O C_{1}=\frac{\pi}{3} \Rightarrow \angle A O A_{1}=\angle C O C_{1}=\frac{\pi}{3} \\
\Rightarrow A A_{1}=\sqrt{3} A O=\sqrt{3} \cdot \frac{\sqrt{2}}{2}=\frac{\sqrt{6}}{2}
\end{array}
$$