agent implementation in python