lib/agent.js
function execute() {
    var res;
    var functionInterface  = {getValueOfAgent: getValueOfAgent};

    if (func) { 
      setWaitingExec(true);
      setTimeout(
          function () {
            var errorOnExecution = false;
            jn.logExecutionEvent(id, 'INFO', 'began function execution', (new Date()).toJSON());
            try {
              res = func(functionInterface);
              setResult(res);
              if (callback) {
                callback(null, res);
              }
              jn.logExecutionEvent(id, 'INFO', 'function executed whitout errors', (new Date()).toJSON());
            } catch (err) {
              errorOnExecution = true; 
              setResult(err);
              jn.logExecutionEvent(id, 'ERROR', 'failed to execute function: ' + err.message, (new Date()).toJSON());
              if (callback) {
                callback(err);
              }
            }
            setExecuted(true);
            setWaitingExec(false);
            if (haltsExecution && errorOnExecution) {
              jn.logExecutionEvent(id, 'ERROR', 'error on execution halted agency execution', (new Date()).toJSON());
              agency.report();
            } else {
              agency.runAgents();
            } 
          }, 0);
    } else {
      jn.logExecutionEvent(id, 'INFO', 'does not have a defined function', (new Date()).toJSON());
    }
  }
function execute() {
    var res;
    var functionInterface  = {getValueOfAgent: getValueOfAgent};

    if (func) { 
      setWaitingExec(true);
      setTimeout(
          function () {
            var errorOnExecution = false;
            jn.logExecutionEvent(id, 'INFO', 'began function execution', (new Date()).toJSON());
            try {
              res = func(functionInterface);
              setResult(res);
              if (callback) {
                callback(null, res);
              }
              jn.logExecutionEvent(id, 'INFO', 'function executed whitout errors', (new Date()).toJSON());
            } catch (err) {
              errorOnExecution = true; 
              setResult(err);
              jn.logExecutionEvent(id, 'ERROR', 'failed to execute function: ' + err.message, (new Date()).toJSON());
              if (callback) {
                callback(err);
              }
            }
            setExecuted(true);
            setWaitingExec(false);
            if (haltsExecution && errorOnExecution) {
              jn.logExecutionEvent(id, 'ERROR', 'error on execution halted agency execution', (new Date()).toJSON());
              agency.report();
            } else {
              agency.runAgents();
            } 
          }, 0);
    } else {
      jn.logExecutionEvent(id, 'INFO', 'does not have a defined function', (new Date()).toJSON());
    }
  }
asynchronously executes the agent's function (wrapper for user defined code) and the optional corresponding callback following the callback contract: callback(error, data); validates the continuation of the agency in case of error during execution of current agent