On Memory as a Self-Adapting Agent