3. If $x-1$ is a factor of $x^{3}+a x^{2}+1$, then the value of $a$ is $\qquad$ .
3. -2 .

Let $x^{3}+a x^{2}+1=(x-1)\left(x^{2}-m x-1\right)$, that is
$$
\begin{array}{l}
x^{3}+a x^{2}+1 \\
=x^{3}-(m+1) x^{2}+(m-1) x+1 .
\end{array}
$$

By comparing, we get $m-1=0, a=-(m+1)$.
Thus, $m=1, a=-2$.