Here is a repository for an agent framework; can you walk me through the code and identify where the reward function is calculated?