LOL. It may be an easy question to answer until you asked "Is this legal?"... Anyways, if your listing contract (and most do) has a "protection" clause, then when your builder makes that 'backup' offer is important to see if you owe your Realtor a commission or not. On the other hand, if you recognize that the market (and not your Realtor) is the cause of your listing not selling, you may want to discuss this will your Realtor and negotiate some kind of flat fee if you accept the Builder's 'backup' offer. I have worked with Builders on this kind of situation as well and have the Builder share a portion of the Realtor's 'flat fee'.
Hope this gives you some ideas to structure a deal acceptable to everybody. Enjoy your new home!