Try this:
$_agent=$modx->getObject('modUser', (int) $profile->get('comment'));
There are some things you could do to speed this up. First, you can use getCollectionGraph() to get the user and the profile in a single query. (In theory, you could get the supervisor's record at the same time, but I don't think it's worth the effort.) This will get all active users and their profiles:
$c = $modx->newQuery('modUser');
$c->sortby('fullname', 'ASC');
$c->where(
array('modUser.active' => '1'),
);
$users = $modx->getCollectionGraph('modUser', '{"Profile":{}}', $c);
Once you have the user and profile, you can create your array like this:
foreach ($users as $user) {
$tmpArray = array_merge($user->Profile->toArray(), $user->toArray());
/* add your extra fields here */
}
Then, create a Tpl chunk with placeholders for the fields and do this:
$output .= $modx->getChunk('MyChunk', $tmpArray;
Finally, here is a much faster way to get the supervisor's name:
$query = $modx->newQuery('modUserProfile', array(
'internalKey' => (int) $user->Profile->get('comment'),
));
$query->select('fullname');
$tmpAgent = $modx->getValue($query->prepare());