Honestly, even a single adversarial reviewer agent, even of the same model, goes a very long way to catching and fixing this kind of thing too.
https://www.coreauto.com/blog/when-ai-starts-writing-systems...
You can have a solution generator and an auditor, but then you will might find a very specific solution to the problem that does not solve the general use-case, so then you might have to adjust the constraints of the problem by for example adding more examples/targets to drive the solution generator to be more general.