move related agent methods in Agent class

Some methods related to agent were located in tasks and taskjobs
classes. It made the code difficult to understand and maintain.