The use of the createSession() method on the Session class is deprecated when running in an agent. Instead, use the getSession() method, which provides the necessary context for the agent.