Get your taxes done using TurboTax

Count every day he stays with you overnight and if it is more then 183 he is still your dependent no matter what the agreement states since the IRS doesn't need to follow those.   Talk with him  and make sure you are both on the same page ... if you both try to claim the same child then it could get ugly and someone will lose and owe back the refund + penalties + interest  which is not in anyone's best interest.