I used to do this regularly when I first started coding, I called them "Codemares". They were like nightmares with the shouting of commands I didn't quite understand would invade my dreams.
IMO this is under-appreciated in current AI models. RL is not very effective in avoiding crocodiles for example, by the time like 5 of your tribe-mates are eaten it's far too late. You need some mechanism that ensures the danger is learned after just a single incident.