One of the reasons this is there is the "psychology" of the LLM performs better with these kinds of affirmations. If you've made a mistake once you're likely to make it again, so leave a note.
This indeed pollutes the code with a bunch of nonsense. One of the things I have it maintain instead is a "findings" document with lessons learned and such.
> If you've made a mistake once you're likely to make it again, so leave a note.
In my experience the comments behave as a form of prompt injection. The llm makes a conceptual mistake, writes it in a comment, and now subsequent agents make the same mistake!