4. In the sequence $\left\{a_{n}\right\}$, $a_{1}=1$. When $n \geqslant 2$, $a_{n}, S_{n}, S_{n}-\frac{1}{2}\left(S_{n}\right.$ is the sum of the first $n$ terms of the sequence $\left\{a_{n}\right\}$) form a geometric progression, then $\lim _{n \rightarrow \infty} n^{2} a_{n}=$ $\qquad$
4. $-\frac{1}{2}$.

From the condition, when $n \geqslant 2$,
$$
S_{n}^{2}=a_{n}\left(S_{n}-\frac{1}{2}\right)=\left(S_{n}-S_{n-1}\right)\left(S_{n}-\frac{1}{2}\right),
$$

Thus,
$$
\frac{1}{S_{n}}-\frac{1}{S_{n-1}}=2
$$

Therefore,
$$
\frac{1}{S_{n}}=\frac{1}{S_{1}}+2(n-1)=2 n-1,
$$

So, $S_{n}=\frac{1}{2 n-1}$. Hence,
$$
a_{n}=S_{n}-S_{n-1}=\frac{1}{2 n-1}-\frac{1}{2 n-3}=-\frac{2}{(2 n-1)(2 n-3)} .
$$

Therefore,
$$
\lim _{n \rightarrow \infty} n^{2} a_{n}=\lim _{n \rightarrow \infty}-\frac{2 n^{2}}{(2 n-1)(2 n-3)}=\lim _{n \rightarrow \infty}-\frac{2}{\left(2-\frac{1}{n}\right)\left(2-\frac{3}{n}\right)}=-\frac{1}{2}
$$