wrote agent method

tasks run in background tasks and takes commands from server