Factorize BaseAgent