4. Let the quadratic function $y=x^{2}+2 a x+\frac{a^{2}}{2}(a<0)$ have its vertex at $A$, and its intersections with the $x$-axis at $B$ and $C$. When $\triangle A B C$ is an equilateral triangle, the value of $a$ is . $\qquad$
4. $-\sqrt{6}$.

The graph of the quadratic function $y=x^{2}+2 a x +\frac{a^{2}}{2}(a<0)$ is shown in Figure 11. Let $A\left(-a,-\frac{a^{2}}{2}\right)$, $B\left(x_{1}, 0\right)$, $C\left(x_{2}, 0\right)$. Denote the intersection of the axis of symmetry with the $x$-axis as $D$, then
$$
\begin{array}{l}
|B C|=\left|x_{1}-x_{2}\right|=\sqrt{\left(x_{1}+x_{2}\right)^{2}-4 x_{1} x_{2}} \\
=\sqrt{4 a^{2}-4 \times \frac{a^{2}}{2}}=\sqrt{2 a^{2}}=-\sqrt{2} a . \\
\text { Also, }|A D|=\frac{\sqrt{3}}{2}|B C| \text {, so }\left|-\frac{a^{2}}{2}\right|=\frac{\sqrt{3}}{2}(-\sqrt{2} a) .
\end{array}
$$

Solving for $a$ gives $a=-\sqrt{6}$ or $a=0$ (rejected).
Thus, $a=-\sqrt{6}$.