7. For all $x \in\left[-2, \frac{1}{2}\right]$, the inequality
$$
a x^{3}-x^{2}+x+1 \geqslant 0
$$

always holds. Then the range of the real number $a$ is $\qquad$ $\because$
7. $-10 \leqslant a \leqslant-1$.

Let $f(x)=a x^{3}-x^{2}+x+1$, the given condition is that $f(x) \geqslant 0$ for all $x \in\left[-2, \frac{1}{2}\right]$.
(1) When $x=0$, for all real numbers $a$, $f(x)=1>0$.
(2) When $x \in\left(0, \frac{1}{2}\right]$,
$$
f(x)=a x^{3}-x^{2}+x+1 \geqslant 0
$$

can be transformed into $a \geqslant \frac{x^{2}-x-1}{x^{3}}$.
Let $g(x)=\frac{x^{2}-x-1}{x^{3}}$. Then
$$
g^{\prime}(x)=-\frac{1}{x^{4}}(x+1)(x-3) .
$$

When $x \in\left(0, \frac{1}{2}\right]$, $g^{\prime}(x)>0$, thus, the function $g(x)$ is monotonically increasing on the interval $\left(0, \frac{1}{2}\right]$, hence,
$$
(g(x))_{\max }=g\left(\frac{1}{2}\right)=-10 .
$$

Therefore, $a \geqslant-10$.
(3) When $x \in[-2,0)$,
$$
f(x)=a x^{3}-x^{2}+x+1 \geqslant 0
$$

can be transformed into $a \leqslant \frac{x^{2}-x-1}{x^{3}}$.
Let $g(x)=\frac{x^{2}-x-1}{x^{3}}$. Then
$$
g^{\prime}(x)=-\frac{1}{x_{4}}(x+1)(x-3) \text {. }
$$

When $x \in(-1,0)$, $g^{\prime}(x)>0$;
When $x=-1$, $g^{\prime}(x)=0$;
When $x \in(-2,-1)$, $g^{\prime}(x)<0$.
Therefore, the function $g(x)$ is monotonically decreasing on the interval $(-2,-1)$ and monotonically increasing on the interval $(-1,0)$. Hence,
$$
(g(x))_{\min }=g(-1)=-1 .
$$

Therefore, $a \leqslant-1$.
In summary, $-10 \leqslant a \leqslant-1$.