Was it Grok 4 Fast by chance?
I was dealing with something similar with it yesterday. No code involved. It was giving me factually incorrect information about a multiple schools and school districts. I told it it was wrong multiple times and it hallucinated school names even. Had the school district in the wrong county entirely. It kept telling me I was wrong and that although it sounded like the answer it gave me, it in fact was correct. Frustrated, I switched to Expert, had it re-verify all the facts, and then it spit out factually correct information.