How the agent works