4. As shown in Figure 4, the line $y = -\frac{\sqrt{3}}{3} x + 1$ intersects the $x$-axis and $y$-axis at points $A$ and $B$, respectively. An isosceles right triangle $\triangle ABC$ with $\angle BAC = 90^{\circ}$ is constructed in the first quadrant with segment $AB$ as one of its legs. If there exists a point $P\left(a, \frac{1}{2}\right)$ in the second quadrant such that the area of $\triangle ABP$ is equal to the area of $\triangle ABC$, then the value of the real number $a$ is $\qquad$
4. $\frac{\sqrt{3}-8}{2}$.

It is easy to know that the intersection points of the line $y=-\frac{\sqrt{3}}{3} x+1$ with the $x$-axis and $y$-axis are $A(\sqrt{3}, 0)$ and $B(0,1)$, respectively, i.e., $O A=\sqrt{3}, O B=1$, then $A B=2$. Therefore, $S_{\triangle A B C}=2$. Thus, $S_{\triangle A B P}=2$.

As shown in Figure 9, connect $O P$, then
$$
\begin{array}{l}
S_{\triangle A O P}=\frac{\sqrt{3}}{4}, \\
S_{\triangle B O P}=-\frac{a}{2}, \\
S_{\triangle A O B}=\frac{\sqrt{3}}{2} .
\end{array}
$$

Since $S_{\triangle B O P}+S_{\triangle A O B}-S_{\triangle A O P}=S_{\triangle A B P}$, we have
$$
-\frac{a}{2}+\frac{\sqrt{3}}{2}-\frac{\sqrt{3}}{4}=2, a=\frac{\sqrt{3}-8}{2} \text {. }
$$