Whenever an AI hallucinates an API call, you run the compiler, give it the error messages and it fixes it. A proper agentic workflow might do it all automatically. These are arguments form 2023 ChatGPT3.5 days when it didn't have tool access or Web search.
The modern problem with AI is more the opposite, you give the AI a task that is impossible with the tools at hand and instead of saying "That doesn't work", it starts elaborate workarounds to make it happen anyway.