2. Let $k$ be a real number, and the quadratic equation $x^{2}+k x+k+1=0$ has two real roots $x_{1}$ and $x_{2}$. If $x_{1}+2 x_{2}^{2}=k$, then $k$ equals $\qquad$ .
2.5.

From $\Delta \geqslant 0$ we get
$$
k^{2}-4 k-4 \geqslant 0 \text {. }
$$

Since $x_{2}^{2}=-k x_{2}-k-1$, then,
$$
\begin{array}{l}
x_{1}+2 x_{2}^{2}=k \Rightarrow x_{1}-2 k x_{2}=3 k+2 \\
\Rightarrow\left(x_{1}+x_{2}\right)-(2 k+1) x_{2}=3 k+2 \\
\Rightarrow-k-(2 k+1) x_{2}=3 k+2 \\
\Rightarrow-(2 k+1) x_{2}=2(2 k+1) \\
\Rightarrow(2 k+1)\left(x_{2}+2\right)=0 .
\end{array}
$$

Since $2 k+1=0$, i.e., $k=-\frac{1}{2}$ does not satisfy (1), thus, $x_{2}=-2$. Substituting into the original equation yields $k=5$.