This isn’t a matter of the ‘agent’ misbehaving. It’s a matter of the developers failure to properly code the agent.
You code the AI LLM framework.
You train the framework's parameters on data.
You don't have a clue what that means, do you?