\(f\left(x\right)⋮\left(x-1\right)\left(x+2\right)\Leftrightarrow\left\{{}\begin{matrix}f\left(1\right)=0\\f\left(-2\right)=0\end{matrix}\right.\)
\(\Leftrightarrow\left\{{}\begin{matrix}a+\left(a+b\right)+\left(2+b\right)+1=0\\-8a+4\left(a+b\right)-2\left(2+b\right)+1=0\end{matrix}\right.\)
\(\Leftrightarrow\left\{{}\begin{matrix}2a+2b=-3\\-4a+2b=3\end{matrix}\right.\) \(\Rightarrow\left\{{}\begin{matrix}a=-1\\b=-\frac{1}{2}\end{matrix}\right.\)