Fix bug in agent log preparation