Open source copyright license can't actually restrict how you use the code. Clever hack though if the log message really did cause agents to delete code!
Of course it can. They can license the code for use under almost any terms they like, including restricting how you use the code.
The GPL imposes conditions on your use of the code / program, as does the MIT License. If you don't follow the conditions then you do not have a license to use the program / code & are open to claims of copyright infringement.
You might choose to ignore the licenses on the code you use, but it certainly isn't a great idea in a commercial context (and in your personal projects probably just a moral dilemma). Although, sadly, I'm not sure any of the many public GPL violations have really "cost" the companies that did them all that much.
Edit: I guess you're saying, yes, you can just go ahead and use it. Which I guess is the position large LLM training corpuses have taken ..
IANAL but if I write a license that says “if you use this with AI Ican shoot you in the head” and I do, that’s probably not going to hold up in court. Deleting someone’s code base isn’t something you can do unilaterally. Likewise, injecting instructions to a computer that causes a malicious act is a crime in the USA.