more agent refactoring to support output file transfer