FindMinimum error related to NDSolve

I’m trying to fit some data into a model using the standard procedure of minimizing the chi-square function using this code:

ClearAll["Global`*"]
Needs["ErrorBarPlots`"];
a0 = 1;
b0 = 2;

sol[a_, b_] := 
NDSolve[{x'[t] == -a*x[t] + Sin[t], y'[t] == a*x[t] - b*y[t]^2, 
z'[t] == b*y[t] - Cos[t], x[0] == 1, y[0] == 0, z[0] == 0}, {x, y,
z}, {t, 0, 10}, MaxSteps -> Infinity];

F[t_] := x[t] + y[t]^2 + z[t]^3;

wsol[a_, 
b_] := (wsol[a, b] = 
NDSolve[{w'[t] - w[t] - ((F[t] /. sol[a, b])[[1]]) == 0, 
w[0] == 0}, w, {t, 0, 10}]);

model[t_, a_, b_] := (w[t] /. wsol[a, b])[[1]] // Chop;

SeedRandom[1264645]; 
rangoT = Range[0, 9, 0.5];
ndat = Length[rangoT];

DATA = Table[{t, 
model[t, a0, b0] + RandomVariate[NormalDistribution[0, .1]], 
RandomReal[{.05, .1}]}, {t, rangoT}];

chi2[a_, b_] := 
Sum[((DATA[[i, 2]] - model[DATA[[i, 1]], a, b])/DATA[[i, 3]])^2, {i, 
1, ndat}]

FindMinimum[chi2[a, b], {w, 0.9}, {b, 1.1}]

But when I run it I get error messages from the FindMinimum command related to NDSolve and ReplaceAll. Everything runs just fine until using that command. I was wondering why’s not working and what should be changed.

fit_test_1.nb (27.1 KB)

The solutions to your first differential equation escape at infinity in finite time, and this time depends on the parameters a,b. However your functions rangoT, DATA and chi2 seem to assume that all your solutions are defined on the same interval [0,9].