2 firms production decision for one agent

I'm trying to solve the optimal production $\{x,y\}$ for a risk neutral agent with weight $w$ in firm $X$ and weight $1-w$ in firm $Y$. Each firm has marginal cost $c^X$ and $c^Y$ respectively. The firms face a linear demand where $P(Q)=a-b Q$ and the total production of the economy $Q=x+y$. This risk neutral agent maximizes profits so his/her utility will be:

$U(x,y)=w(x(a-b(x+y)-c^X))+(1-w)(y(a-b(x+y)-c^Y))$

If I take first order conditions to maximize this utility I get:

$(a-2b x-c^X)w-by=0$

$(a-2b y-c^Y)(1-w)-bx=0$

Which solves to:

$x=\frac{(1-w)(2 c^X w-c^Y+a(1-2 w))}{b(1-2w)^2}$

$y=\frac{w(2 c^Y(1- w)-c^X-a(1-2 w))}{b(1-2w)^2}$

Assuming this is all correct, I don't understand why when $w=0$, then $y=0$!!! and $x=\frac{a-c^Y}{b}$ maxing the utility $U(x,y)=0$.

I think this doesn't make sense and can't be the optimum because having $x=0$ and $y=\frac{a-c^Y}{2b}$ (monopoly production) would give $U(x,y)=\frac{(a-c)^2 }{2b}>0$

I must have something wrong, the derivatives and solutions are correct, does anyone see what I'm missing here?

Seems like you are assuming there will be an interior solution. $$(a-2b x-c^X)w-by = 0$$ only needs to hold if the value of $x$ is positive. If it is not, but $x = 0$, the lowest possible amount, then $$(a-2b x-c^X)w-by < 0$$ is not a contradiction. Further decreasing $x$ would increase utility, but it is not possible. Therefore in the case when $w = 0$ and $$(a-2b x-c^X)w-by = -by$$ you do not necessarily have $y = 0$.