fix AgentFactory (redundant parameter) + open up function in QueryTool