fixed bug in agent.py