Migrate agent to python3