Charlie Sheen and Brooke Mueller have agreed to a joint custody deal.

Lawyers for the pair told a judge in Los Angeles today they have managed to come to an agreement over two-year-old twins Bob and Max, which will see them share legal and physical custody of the kids.

According to gossip website TMZ, Brooke will get more time with the children then her former husband although the signed agreement will not be filed in court in order to keep the terms completely confidential.

The deal comes less than a month after Charlie slammed the judge who refused to award him sole access to the boys.

He said: "I thought it was a s**t sandwich. Two slices of bread filled with s**t. Seemed like there were rules in place and it seemed like someone didn't follow them. And there's no consequences, so I don't get it. System is broke, you know."

This truce with Brooke will provide some good news for Charlie , who recently failed in a bid to get increased access to his daughters Sam, seven, and Lola, five, with ex-wife Denise Richards.

A source said: "Denise wants Charlie to be healthy. She wants the girls to see him, but he has to change.

"This is up to Charlie. If he wants to be a dad, he can be. But he has to prove he's healthy and has his life in order."