\(x^3+4x^2+ax+b=x\left(x^2+x-2\right)+3\left(x^2+x-2\right)-x+ax+6+b\)
\(=\left(x^2+x+2\right)\left(x+2\right)-x+ax+6+b⋮\left(x^2+x+2\right)\)
\(\Rightarrow-x+ax+6+b=0\)
\(\Rightarrow\left\{{}\begin{matrix}ax=x\\b=-6\end{matrix}\right.\)\(\Rightarrow\left\{{}\begin{matrix}a=1\\b=-6\end{matrix}\right.\)