fix bugs in agent dir service