I think that's been discussed before, I can't find a thread at the moment, but I believe there have been about as many versions as there are people on this board
I think I would do one of two things:
One version would be to have it be a plot device and compel it at a critical moment. Probably the most elegant, since you can chose the moment it has the most interesting effect on the story.
The second would be to have the player take all casting stress in advance, as much as he likes, including consequences, and then let him cast as long as he has juice in the form of pre-paid stress.
But if you look at it, Harry wasn't really beaten because he couldn't use magic, he was beat because of the second part of the denarian's plan. Ivy was casting till the very end, so where the Denarians. Harry had to carry Ivy at that point, so casting wasn't really an option.