The best "solution" I've got so far is to put
$ansHash->{prev_ans}='';
at the beginning of the custom checker, to wipe memory of the previous answer. This band-aids the issues I describe below, but I think it would be better just to turn off this comparison in these kinds of problems.
----
There are two ways in which this is causing trouble. One is that a student might submit something like "4x/2" and be told their answer is incorrect because the custom checker is examining the form of the answer. Then they try the correct answer "2x", and it is marked correct, and the message "this is equivalent to your previous answer" is given, presumably because the "4x/2" is compared to the "2x" without any custom method of comparison. A feedback message like "this is equivalent to your previous answer" is undesirable in this situation.
The second issue is something I cannot fully explain, but I am convinced it has to do with this comparison to the previous answer. Again using one of our complicated custom checkers, a student might submit an answer. What happens sometimes is that a WeBWorK error message (not a student feedback message) arises:
Please inform your instructor that an error occurred while checking your answer at [PG]/lib/Value/AnswerChecker.pm line 254
And experimentation (that I won't go into, unless someone asks for it) is suggesting that this is stemming from there being no definition of what it means to compare the answer and the previous answer. That is, I think the defined($equal) in AnswerChecker.pm line 250 is working out to false.