Charlie Sheen and his estranged wife Brooke Mueller will undergo random drug tests every month as part of their formalised custody agreement.
The former couple has thrashed out the details of their custody arrangements for their twin sons, Bob and Max, and they have both agreed to remain drug and alcohol free.
According to the official agreement, filed in Los Angeles County Superior Court and obtained by TMZ.com, both Sheen and Mueller will submit to three random drug exams every month.
Both parents must also have their nannies accompany them at all times when they are looking after the kids, and are banned from being photographed with a romantic partner and the boys.
The former Two and a Half Men star will have custody of the twins every other weekend for the first two months and in the following two months he will get to spend three days per week with them.
The estranged couple wed in 2008 but they split after a bust-up the following year, which left the actor with an assault conviction.
Sheen, who has been a tabloid regular over the last few months with his bizarre behavior, appears to have settled his differences with Mueller after she agreed to let her restraining order against him expire.